Knowee
Questions
Features
Study Tools

Q. 3 (10 marks) Consider the following data structure for representing a set. The elements of the set are stored in a singly linked list of sorted arrays, where the number of elements in each array is a power of 2 and the sizes of all the arrays in the list are different. Each element in the set occurs in exactly one array. The arrays in the linked list are kept in order of increasing size. To perform SEARCH, perform binary search separately on each array in the list until either the desired element is found, or all arrays have been considered. To insert a new element x into the set (given the precondition that x is not already in the set), create a new array of size 1 containing * insert this new array at the beginning of the linked list while the linked list contains 2 arrays of the same size merge the 2 arrays into one (sorted) array of twice the size (a) Draw the data structure that results after inserting the following sequence of elements into an initially empty set: 2, 63, 1, 32, 77, 7 (b) What is the worst-case time, to within a constant factor, for performing SEARCH when the set has size n? Justify your answer. HINT: Using the following notation may help you express your answer: "Let I, denote the set of bit positions in the binary representation of n that contain the value 1.". (c) What is the worst-case time, to within a constant factor, for performing INSERT when the set has size ?? Justify your answer. (dd) Use the aggregate method to prove that the amortized insertion time in a sequence of n insertions, starting with an initially empty set, is ?(??g ?). (e) Use the accounting method to prove that the amortized insertion time in a sequence of ? insertions, starting with an initially empty set, is ?(??g ?) Q. 4 (5 marks) Suppose you want to find connected components using disjoint sets on undirected graph G = (V, E). where V = (2, 2, 2, 2, 2, 2, 2, 2, 2, ?, ?) and the edges in the E are processed in the order List the vertices in each connected component after each iteration of find-set and union. Show all the steps. Q. 5 (15 marks) Disprove following claim with an example: The height of ? node Fibonacci heap is always ?(??g ?) . Use following argument to disprove the claim. a) [10 points] Show that for any positive number of nodes ?, a sequence of Fibonacci heap operations that create a Fibonacci heap that consists of one tree that is a linear chain of ? nodes.

Question

Q. 3 (10 marks) Consider the following data structure for representing a set. The elements of the set are stored in a singly linked list of sorted arrays, where the number of elements in each array is a power of 2 and the sizes of all the arrays in the list are different. Each element in the set occurs in exactly one array. The arrays in the linked list are kept in order of increasing size. To perform SEARCH, perform binary search separately on each array in the list until either the desired element is found, or all arrays have been considered. To insert a new element x into the set (given the precondition that x is not already in the set), create a new array of size 1 containing * insert this new array at the beginning of the linked list while the linked list contains 2 arrays of the same size merge the 2 arrays into one (sorted) array of twice the size (a) Draw the data structure that results after inserting the following sequence of elements into an initially empty set: 2, 63, 1, 32, 77, 7 (b) What is the worst-case time, to within a constant factor, for performing SEARCH when the set has size n? Justify your answer. HINT: Using the following notation may help you express your answer: "Let I, denote the set of bit positions in the binary representation of n that contain the value 1.". (c) What is the worst-case time, to within a constant factor, for performing INSERT when the set has size ?? Justify your answer. (dd) Use the aggregate method to prove that the amortized insertion time in a sequence of n insertions, starting with an initially empty set, is ?(??g ?). (e) Use the accounting method to prove that the amortized insertion time in a sequence of ? insertions, starting with an initially empty set, is ?(??g ?) Q. 4 (5 marks) Suppose you want to find connected components using disjoint sets on undirected graph G = (V, E). where V = (2, 2, 2, 2, 2, 2, 2, 2, 2, ?, ?) and the edges in the E are processed in the order List the vertices in each connected component after each iteration of find-set and union. Show all the steps. Q. 5 (15 marks) Disprove following claim with an example: The height of ? node Fibonacci heap is always ?(??g ?) . Use following argument to disprove the claim. a) [10 points] Show that for any positive number of nodes ?, a sequence of Fibonacci heap operations that create a Fibonacci heap that consists of one tree that is a linear chain of ? nodes.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

This is a complex set of questions involving data structures and algorithms. Let's break it down:

Q3.

(a) After inserting the elements 2, 63, 1

Similar Questions

91. Which of the following data structures are indexed structures?#a) linear arraysb) linked listsc)Dequesd) Treese)Stacks92. Which of the following is not the required condition for binary search algorithm?a) The list must be sortedb) there should be the direct access to the middle element in any sublist#c)There must be mechanism to delete and/or insert elements in listd) The list must be partitionede) none of the above93. Which of the following is not a limitation of binary search algorithm?a) must use a sorted arrayb) requirement of sorted array is expensive when a lot of insertion and deletions areneededc)there must be a mechanism to access middle element directly#d) binary search algorithm is not efficient when the data elements are more than 1000.e) both a and b94. A variable P is called pointer if#a)P contains the address of an element in DATA.b) P points to the address of first element in DATAc) P can store only memory addressesd) P contain the DATA and the address of DATAe) P can store only the DATA95. Which of the following data structure can't store the non-homogeneous data elements?#a)Arraysb) Recordsc)Pointersd) LinkedListe)Trees96. Which of the following data structure store the homogeneous data elements?

In which of these data structures is binary search possible?A linked list with items in sorted order.A queue with items in sorted order from the head to the tail of the queueA stack with items in sorted order from the bottom to the top of the stackAn array with items in sorted order.

Cheat SheetThis is a compilation of worst-case complexities for various data-structures and algorithms.Data-StructuresData Structure Worst Case Complexity NotesArray Insert O(1)Retrieve O(1)Linked List Insert at Tail O(n)Insert at Head O(1)Retrieve O(n)Note that if new elements are added at the head of the linkedlist then insert becomes a O(1) operation.Binary Tree Insert O(n)Retrieve O(n)In worst case, the binary tree becomes a linked-list.Dynamic Array Insert O(1)Retrieve O(1)Note by retrieving it is implied we are retrieving from a specific index of the array.Stack Push O(1)Pop O(1)There are no complexity trick questions asked for stacks or queues. We only mention them here for completeness. The two data-structures are more important from a last-in last-out (stack) and first in first out (queue) perspective.Queue Enqueue O(1)Dequeue O(1)Priority Queue (binary heap) Insert O(lgn)Delete O(lgn)Get Max/Min O(1)Hashtable Insert O(n)Retrieve O(n)Be mindful that a hashtable's average case for insertion and retrieval is O(1)B-Trees Insert O(logn)Retrieve O(logn)Red-Black Trees Insert O(logn)Retrieve O(logn)AlgorithmsCategory Worst Case Complexity NotesSorting Bubble Sort O(n2)Insertion Sort O(n2)Selection Sort O(n2)Quick Sort O(n2)Merge Sort O(nlgn)Note, even though worst case quicksort performance is O(n2) but in practice quicksort is often used for sorting since its average case is O(nlgn).Trees Depth First Search O(n)Breadth First Search O(n)Pre-order, In-order, Post-order Traversals O(n)n is the total number of nodes in the tree. Most tree-traversal algorithms will end up seeing every node in the tree and their complexity in the worst case is thus O(n).

what is binary search in data structures?Give me the content for 5 marks

"Data Structures and Algorithms

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.