
data structures and algorithms

Quiz
•
Computers
•
University
•
Medium
Shakshi ranawat
Used 6+ times
FREE Resource
25 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following definition in c programming language.
struct node
{
int data;
struct node next;
}
typedef struct node NODE;
NODE ptr;
Which of the following c code is used to create new node?
ptr = (NODE*)malloc(sizeof(NODE));
ptr = (NODE*)malloc(NODE);
ptr = (NODE*)malloc(sizeof(NODE*));
ptr = (NODE)malloc(sizeof(NODE));
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to access the data field of a node in the linked list defined above?
ptr->data;
ptr.data;
*ptr.data;
data.ptr;
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements correctly frees the memory allocated for a node?
free(ptr);
delete ptr;
ptr = NULL;
dispose(ptr);
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the context of the given struct, what does the 'next' pointer represent?
It points to the previous node.
It points to the next node in the linked list.
It is a null pointer.
It stores the size of the node.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?
i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the last node of the linked list
I and II
I and III
I, II and III
I, II and IV
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code perform ?
void function(struct Node* head)
{
while (head != NULL)
{
printf("%d -> ", head->data);
head = head->next;
}
printf("NULL\n");
}
Deleting a node
Printing the link list elements
Searching an element in link list
none
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code snippet?
void function(struct Node* head) {
if (head == NULL) return;
function(head->next);
printf("%d ", head->data);
}
Elements in reverse order
Elements in original order
Only the first element
None of the above
Create a free account and access millions of resources
Similar Resources on Wayground
24 questions
Midterm 2 Review Quiz

Quiz
•
University
20 questions
Assignment Quiz-2

Quiz
•
University
20 questions
Exploring Big Data Concepts

Quiz
•
University
23 questions
DSC UNIT 4 Quiz

Quiz
•
University
20 questions
Node.js Server

Quiz
•
University
25 questions
Quiz 4

Quiz
•
University
25 questions
UAS DPK

Quiz
•
University
20 questions
Wireless Networks Quiz 3

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University