Question: Time Complexity: two questions Q2: Given a linked list, and two numbers x & y, from the start of the linked list to the
Time Complexity: two questions Q2: Given a linked list, and two numbers x & y, from the start of the linked list to the end, skip x nodes and then delete y number of nodes and then skip x number of nodes and then delete y nodes repeatedly until the end of the linked list, your method will be something like skipAndDelete(Node head, int x, int y), for example: skipAndDelete(head, 2,3) for this linkedlist (1,3,5,2,5,11,9,6,7,4,-1,3,4} would make the list as following: (1,3,11,9,-1,3). You have to write the code/algorithm. Q3: Given a queue filled with data, and a number n, you have to flip the first n nodes. For example: if the queue is like this: [A|B|C| D|E|F|G|H], where H is at the end of the queue (first pushed) and A is the front at the queue (last pushed), given a number n=3, the result queue should be like this: [C|B|A|D|E|F|G|H], first 3 elements where reversed/flipped. Write your code. Q4: Given a max heap array, write the code that converts it to a min heap. Q5: Trace the following AVL tree, insert #,#,#, delete #, ... and so.. Q6: Trace the following Hash Set, given a table with three columns, one for linear probing, one for quadratic and one for double hashing. insert #,#,#,#,#,#... and so.. Q7: Trace the following Min Heap, insert #,#,#, delete #, ... and so.. Q8: For each of the following sorting algorithms, write the time complexity of the algorithms in the given case. Ex: Bubble Sort for random data? n Merge sort for sorted data? nlogn
Step by Step Solution
There are 3 Steps involved in it
Q2 Skip and Delete in a Linked List class ListNode def initself val0 nextNone selfval val selfnext next def skipAndDeletehead x y if not head return N... View full answer
Get step-by-step solutions from verified subject matter experts
