DSA quiz 3 set 1
Quiz
•
Computers
•
University
•
Medium
Shubham (M21CS016)
Used 5+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider a directed, weighted graph G = (V, E) with weight function w: E→R. For some function f: V→R, for each edge (u, v) ∈ E, define w'(u, v) as w(u, v) + af(u) - bf(v), where a and b are two constants.
Which one of the options completes the following sentence so that it is TRUE?
“The shortest paths in G under w are the shortest paths under w’ too, ______”.
If a = b
If a<b
If a>b
Any value of a and b
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Let G be a graph with 100! vertices, with each vertex labeled by a distinct permutation of the numbers 1, 2, …, 100. There is an edge between vertices u and v if and only if the label of u can be obtained by swapping two adjacent numbers in the label of v. Let y denote the degree of a vertex in G, and z denote the number of connected components in G. Then y + z = _______ .
100
110
109
None of these
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider BFS on a binary tree starting from the root node. There is a vertex t at a distance 6 from the root. If t is the nth vertex in this BFS traversal, then the minimum and maximum possible values of n are ________
32,64
31,63
64,127
127,128
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider following statements written in C
i) sizeof(int)
ii) sizeof(int*)
iii) sizeof(int**)
Consider the size of int as 4 bytes and size of pointer as 4 bytes. Pick the correct option -
Only i) would compile successfully, and it would return size as 4.
i), ii) and iii) would compile successfully and the size of each would be same i.e. 4
i), ii) and iii) would compile successfully, but the size of each would be different and would be decided at run time
ii) and iii) would result in compile error but i) would compile and result in size as 4.
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code snippet.
#include <stdlib.h>
int main()
{
int *ptr;
int **ptr1;
int **ptr2;
ptr = (int*)malloc(sizeof(int));
ptr1 = (int**)malloc(10*sizeof(int*));
ptr2 = (int**)malloc(10*sizeof(int*));
free(ptr);
free(ptr1);
free(*ptr2);
return 0;
}
Pick the Correct option -
malloc() for ptr1 and ptr2 isn’t correct. It’ll give a compile time error.
free(*ptr2) is not correct. It’ll give a run time error.
free(*ptr2) is not correct. It’ll give a compile time error.
No issue with any of the malloc() and free() i.e. no compile/run time error.
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which data structure is best suited to print the documents in the printer?
Queue
Stack
Linked List
Array
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code snippet.
#include <stdio.h>
int func(int *a, int data)
{
*a = data;
return a;
}
int main()
{
int *x = malloc(sizeof(int));
if (NULL == x) return;
x = func(x, 0);
if(x)
{
x = (int*) malloc(sizeof (int));
if (NULL == x) return;
x = func(x, 10);
}
printf("%d\n", *x);
free(x);
}
compiler error because the comparison should be made as x==NULL and not as shown.
compiler error as the return of malloc is not typecast appropriately.
compiles successfully but execution may result in memory leak.
compiles successfully but execution may result in dangling pointer.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple

Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
10 questions
Pointeurs et références 2
Quiz
•
University
10 questions
OOPJ- Data Types-Java
Quiz
•
University
10 questions
Introduction to Python
Quiz
•
University
10 questions
Tercer palcial INFORMÁTICA V QB-FM
Quiz
•
University
10 questions
แบบทดสอบหุ่นยนต์ระดับกลางเบื้องต้น
Quiz
•
6th Grade - University
10 questions
Vocational English for Game Design
Quiz
•
University
12 questions
Android App Development
Quiz
•
University
11 questions
C Language
Quiz
•
10th Grade - University
Popular Resources on Wayground
20 questions
Brand Labels
Quiz
•
5th - 12th Grade
11 questions
NEASC Extended Advisory
Lesson
•
9th - 12th Grade
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
10 questions
Multiplication and Division Unknowns
Quiz
•
3rd Grade
20 questions
Multiplying and Dividing Integers
Quiz
•
7th Grade
Discover more resources for Computers
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
22 questions
FYS 2024 Midterm Review
Quiz
•
University
20 questions
Physical or Chemical Change/Phases
Quiz
•
8th Grade - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
12 questions
1 Times Tables
Quiz
•
KG - University
20 questions
Disney Trivia
Quiz
•
University
38 questions
Unit 6 Key Terms
Quiz
•
11th Grade - University