0% found this document useful (0 votes)
3 views4 pages

In-Course Exam: Algorithm Questions

The document contains a series of programming tasks requiring algorithms in pseudocode for sorting a list with three unsorted items, merging two sorted linked lists, generating words from specific letters, finding the largest number smaller than a given k in a sorted array, and analyzing the output of provided C++ code snippets. Each task specifies the requirements and examples for clarity. The document is structured to assess algorithmic efficiency and understanding of data structures.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

In-Course Exam: Algorithm Questions

The document contains a series of programming tasks requiring algorithms in pseudocode for sorting a list with three unsorted items, merging two sorted linked lists, generating words from specific letters, finding the largest number smaller than a given k in a sorted array, and analyzing the output of provided C++ code snippets. Each task specifies the requirements and examples for clarity. The document is structured to assess algorithmic efficiency and understanding of data structures.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Roll: ____ Time: 1 hour Marks: 15

1. You are given a list of numbers as input where all the items except three are placed in sorted order. 3
Write down an efficient algorithm (pseudocode) for sorting the entire list. Mention the runtime and space
complexity of your algorithm.
2. You are given two head nodes of two sorted singly linked list as input. Write down an efficient algorithm 3
(pseudocode) for combining both the lists into one. The resultant linked list must have to be sorted.
Example: Linked list 1: {1,3,4} ; Linked list 2: {2, 5} => result: {1, 2, 3, 4, 5}
3. Write down an algorithm (pseudocode) for printing all the words: (i) consisting of letters {A, B, C}, (ii) of 3
length K where K>5, (iii) having more than four “A”.

4. You are given a sorted array of numbers and a number k as input. Write down an efficient algorithm 3
(pseudocode) for finding the largest number in the array that is smaller than k. Mention the runtime and
space complexity of your algorithm.
5. Write down the output of the following codes. 3

(a) (b)
#include <iostream> #include <iostream>
using namespace std; using namespace std;
void pr(int n){ void fun(int n) {
if(n<1) return; if (n > 0) {
pr(n/2); fun(n - 1);
cout<<n; cout << n;
} fun(n - 1);
int main() { }
pr(17); }
return 0; int main()
} {
fun(4);
return 0;
}

You might also like