Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSC 300 Data Structures I Exams: Questions, Formulas, and Answers, Exams of Computer Science

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

2024/2025

Available from 12/22/2024

Martin-Ray-1
Martin-Ray-1 🇺🇸

5

(8)

6.1K documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSC 300 Data Structures I Exams
Questions Formulas and Answers.
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)
pf3
pf4
pf5
pf8

Partial preview of the text

Download CSC 300 Data Structures I Exams: Questions, Formulas, and Answers and more Exams Computer Science in PDF only on Docsity!

CSC 300 Data Structures I Exams

Questions Formulas and Answers.

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; } } }