Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CSD201 Questons and Answers 2024

Rating
-
Sold
-
Pages
53
Grade
A+
Uploaded on
13-11-2024
Written in
2024/2025

CSD201 Questons and Answers 2024 5. 5. Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among union, intersection, membership, cardi- nality will be the slowest? a. union, intersection b. membership, cardinality c. intersection, membership d. union only: a 6. 6. What are the time complexities of finding 8th element from beginning and 8th element from end in a singly linked list? Let n be the number of nodes in linked list, you may assume that n 8 a. O(1) and O(n)

Show more Read less
Institution
Course

Content preview

CSD201 Questons and Answers 2024



1. 1. What does the following function do for a given Linked List with first node as head?

void fun1(node head)
{ if(head == NULL)
return; fun1(head.next);
System.out.write(head.data);
}

a. Prints all nodes of linked list in reverse order
b. Prints all nodes of linked lists
c. Prints alternate nodes of Linked List
d. Prints alternate nodes in reverse order: a
2. 2. Which of the following sorting algorithms can be used to sort a random linked list with
minimum time complexity?

a. Merge Sort
b. Insertion Sort
c. Quick Sort
d. Heap Sort: a
3. 3. What is the output of following function for start pointing to first node of following linked list?
1->2->3->4->5->6


void fun(node* start)
{
if(start == NULL)
return;
System.out.write(start.data);


if(start.next != NULL )
fun(start.next.next);
System.out.write(star.data);



, CSD201 Questons and Answers 2024

}
a. 1 3 5 5 3 1
b. 1 4 6 6 4 1
c. 1 3 5 1 3 5
d. 1 2 3 5: a

4. 4. In the worst case, the number of comparisons needed to search a singly linked list of length n
for a given element is

a. n
b. n/2






, CSD201 Questons and Answers 2024



c. log¬2n -1
d. log¬2n: a
5. 5. Suppose each set is represented as a linked list with elements in arbitrary order. Which of the
operations among union, intersection, membership, cardi- nality will be the slowest?

a. union, intersection
b. membership, cardinality
c. intersection, membership
d. union only: a
6. 6. What are the time complexities of finding 8th element from beginning and 8th element from
end in a singly linked list? Let n be the number of nodes in linked list, you may assume that n > 8

a. O(1) and O(n)
b. O(1) and O(1)
c. O(n) and O(1)
d. O(n) and O(n): a
7. 7. Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head
node is not given, can we delete the node X from given linked list?

a. Possible if X is not last node. Use following two steps (a) Copy the data of next of X to X. (b)
Delete next of X.

b. Possible if size of linked list is even
c. Possible if size of linked list is odd
d. Possible if X is not first node. Use following two steps (a) Copy the data of next of X to X. (b)
Delete next of X: a

8. 8. You are given pointers to first and last nodes of a singly linked list, which of the following
operations are dependent on the length of the linked list?

a. Delete the last element of the list
b. Delete the first element


, CSD201 Questons and Answers 2024

c. Insert a new element as a first element
d. Add a new element at the end of the list: a
9. 9. Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is
the worst-case time complexity of the best known algorithm to delete the node x from the list?

a. O(1)
b. O(n)
c. O(logn)
d. O(log2n): b

Written for

Course

Document information

Uploaded on
November 13, 2024
Number of pages
53
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
smartchoices Chamberlain College Of Nursing
Follow You need to be logged in order to follow users or courses
Sold
36
Member since
5 year
Number of followers
5
Documents
4499
Last sold
3 weeks ago

4.8

9 reviews

5
7
4
2
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions