




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A collection of questions and answers related to data structures, covering topics such as runtime analysis, sorting algorithms, and common data structures like arrays, linked lists, queues, stacks, and heaps. It includes examples of code snippets and step-by-step solutions for various data structure operations, making it a valuable resource for students studying data structures.
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!
What is the runtime? for (int i = 1; i < N; i = i*2) for (int j = 0; j < i; j++) count++; - Correct: ✔✔Linear What is the runtime? for (int i = 1; i < N; i++) for (int j = 0; j < N; j++) count++; - Correct: ✔✔Quadratic What is the runtime? a[1] = a[0]+13; - Correct: ✔✔Constant What is the runtime? for (int i = N; i > 0; i = i/2)
count++; - Correct: ✔✔Logaithmic What is the runtime? for (int i = N; i > 0; i = i/2) for (int k = 0; k < N; k++) count++; - Correct: ✔✔Linearithmic Insertion Sort Worst, Average, and Best Case runtime - Correct: ✔✔Worst: N^ Average: N^ Best: N Selection Sort Worst, Average, and Best Case runtime - Correct: ✔✔Worst: N^ Average: N^ Best: N^ Merge Sort
Initialize the array from the heap structure T P R N H O A E I G - Correct: ✔✔T P R N H O A E I G Add L To this Heap Structure T P R N H O A E I G - Correct: ✔✔T P R N L O A E I G H Add Z To this Heap Structure T P R N L O A E I G H - Correct: ✔✔Z P T N L R A E I G H O Add K To this Heap Structure Z P T N L R A E I G H O - Correct: ✔✔Z P T N L R A E I G H O K Delete the Max of this Heap Structure Z P T N L R A E I G H O K - Correct: ✔✔T P R N L O A E I G H K
Describe this Data Structure Array - Correct: ✔✔Binary search, Fixed size, constant time for finding an element Describe this Data Structure Linked List - Correct: ✔✔No fixed length, easy to add and delete elements Describe this Data Structure Queue - Correct: ✔✔First in, First out Describe this Data Structure Stack - Correct: ✔✔Last in First out Describe this Data Structure Heap - Correct: ✔✔Semi-sorted, priority queue
exch(a, j, j-; } - Correct: ✔✔Insertion Sort N^ Write a function that deletes every other node in a linked list. - Correct: ✔✔Public static void deleteEveryOther(Node First) { if (first == null) return; Node curr = first; while (curr != null && curr.next != null) { curr.next = curr.next.next; curr = curr.next; } } Write a function that adds every even element of the linked list together. - Correct: ✔✔public int sum(Node first){ int sum=0; Node x=first; if (first==null){ return sum; }
while (x!=null){ if (x.item % 2 == 0){ sum+=x.item; x=x.next; } else{ x=x.next; } } }