My Report

Data Structure I Mock Test 4


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. Identify the reason which doesn’t play a key role to use threaded binary trees?

Question 1 of 10

Question 2 of 10

2. If binary trees are represented in arrays, what formula can be used to locate a left child, if the node has an index i?

Question 2 of 10

Question 3 of 10

3. Which of the following is an advantage of XOR list?

Question 3 of 10

Question 4 of 10

4. What's wrong with this code which returns xor of two nodes address ?

//struct is common userdefined datatype in c/c++ and class is it's alternative

struct node* XOR (struct node *a, struct node *b) 
{
    //this logic is used to fill the nodes with address of a xor linked list
    return  ((int) (a) ^ (int) (b));   
}

Question 4 of 10

Question 5 of 10

5. Skip lists are similar to which of the following datastructure?

Question 5 of 10

Question 6 of 10

6. What will be the time complexity of the following code?

#include <iostream>
using namespace std;
int main()
{   
    int arr[] = {1,2,3,4,5,6};
    int n = sizeof(arr)/sizeof(arr[0]);
    int d=4;
    int temp[10];
    
    for(int i=0;i<d;i++)
    temp[i]=arr[i];
    
    int j=0;
    for(int i=d;i<n;i++,j++)
    arr[j]=arr[i];
    
    int k=0;
    for(int i=n-d;i<n;i++,k++)
    arr[i]=temp[k];
    
    for(int i=0;i<n;i++)
    cout<<arr[i]<<" ";
    return 0;
}

Question 6 of 10

Question 7 of 10

7. The following given tree is an example for?
binary-tree-operations-questions-answers-q2

Question 7 of 10

Question 8 of 10

8. What will be the time complexity of the following code?

#include <bits/stdc++.h> 
using namespace std; 
void func1(int arr[], int n) 
{ 
	int k = arr[0], i; 
	for (i = 0; i < n - 1; i++) 
		arr[i] = arr[i + 1]; 

	arr[i] = k; 
} 

void func(int arr[], int d, int n) 
{ 
	for (int i = 0; i < d; i++) 
		func1(arr, n); 
} 

void printArray(int arr[], int n) 
{ 
	for (int i = 0; i < n; i++) 
		cout << arr[i] << " "; 
} 

int main() 
{ 
	int arr[] = { 1, 2, 3, 4, 5}; 
	int n = sizeof(arr) / sizeof(arr[0]); 

    int d = 3;
	func(arr, d, n); 
	printArray(arr, n); 

	return 0; 
} 

Question 8 of 10

Question 9 of 10

9. The self organizing list improves _____

Question 9 of 10

Question 10 of 10

10. How many orders of traversal are applicable to a binary tree (In General)?

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.