Write an algorithm to find the sum of n elements after a kth smallest element in Binary Search Tree. (Java)
Write an algorithm to find the sum of n elements after a kth smallest element in...
1. Suppose you are implementing the address book feature for a cellphone. The address book needs to be kept sorted by person’s last name and support fast access when queried by last name. Which of the following data structures would be a good choice to use for storing the address book? Explain why. Which would be the bad choice and why? a. unsorted linked list (b) sorted linked list b. binary search tree (d) hash table. 2. Write an algorithm...
write the method that return the kth smallest item in the binary search tree. for example if the tree has 18 node and the user enter 13 then the method should return the 13 smallest element in the tree. I has a method that done it recursively but I want to Implement findKth nonrecursively public String findKth( String k ) { return findKth( k, root).data; } public Node findKth(int k, Node t ) { if( t...
I also don't quite understand the meaning of N.size, is N.size (the sum of nodes) (a node and its sub trees) has? please also explain that, thank you. modify the standard definition of a binary search tree to add a field N.size at each Suppose that we node, which records the size of the subtree under N'Tincluding N itself). A. Explain how to modify the procedure for adding both the case where X is not yet in the tree and...
Provide an O(k log k) algorithm that uses a heap data structure to find the kth largest element from the heap of n elements where n > k. Sketch your algorithm. (Hint: You may need to use an additional heap) Use the example data below to demonstrate the process. (e.g. Find the 7 largest element from this heap and it should be 45) Justify the running time. Heap H 100 80 70 40 50 65 60 20 40 10 30...
Need help with my Java Hw: Consider an algorithm that sorts an array of n elements by finding the smallest and largest elements and then exchanges those elements with the elements in the first and last positions in the array. Then the size of the array is reduced by two elements after excluding the two elements that are already in the proper positions, and the process is repeated on the remaining part of the array until the entire array is...
Write just Algorithm for Given an array of n elements, write an algorithm to find a number that has a duplicate.
Given a list of numbers in random order, write an algorithm that works in O( n log(n) ) to find the kth smallest number in the list.
I need question 9-10 answered. Thank you Question 1 iShow the resulting binary search tree if we are to insert following elements into the tree in given order, [34, 12, 23, 27,31,9,11,45, 20, 37. i) Show the resulting balanced binary search tree if we are to insert following sorted elements into the tree, [9,12,21, 23, 29, 31, 34, 45, 48, 52, 55] iii What is the pre-order traversal of the balanced binary search tree? v) What is the post-order traversal...
b) Design a presorting-based algorithm to find the smallest possible mean of k elements in an array of n elements. Algorithm SmallestKMean (AI1. .n], k) c)Consider the problem of searching for genes in DNA sequences using Boyer-Moore string matching algorithm. A DNA sequence is represented by a text on the alphabet (A, C, G, T), and the gene or gene segment is the pattern. Construct the bad-symbol shift table and good-suffix shift table for the following gene segment: TAATAA Apply...
Write an algorithm that will check if a tree is a binary search tree. If a tree is not a binary search tree, then it will repair it to make it one. (a) Write pseudo-code for both functions. (b) What is the running time for your algorithm?