SlideShare a Scribd company logo
1 of 4
Download to read offline
National School of Business Management
Algorithms and Data Structures
CS106.3 - 16.2 Examination
Time: 03Hrs
Answer all Questions Date: 2017
Question 1 – 20 Marks
(a) What is asymptotic analysis in the context of evaluation of Algorithms? [5 Marks]
(b) Simplify the following Big-O expressions [10 Marks]
i. O(10n4-n2-10)
ii. O(2n3+102n) * O(n)
iii. O(n2) + O(5*log(n))
iv. O(n2) * O(5*log(n))
v. n2*O(n2)
(c) Giving reasons, evaluate the time complexity of the following function. [5 Marks]
int swapping;
do {
for(i=0,swapping=0;i<size-1;i++)
if(data[i]>data[i+1]) { temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
swapping=1;
}
} while(swapping)
Question 2 - 20 Marks
Following loop implements the insertion sort algorithm.
1 for(k=1; k<size; k++){
2 for(i=0; i<k && d[i]<=d[k]; i++);
3 temp=d[k];
4 for(l=k;l>i;l--) d[l]=d[l-1];
5 d[i]=temp;
6 }
(a) Write a complete C function to implement the insertion sort algorithm. [5 marks]
(b) Write down a comment line for each and every line in the above C function in part (a). If
necessary number the lines in the C function and write the comments separately with
the line numbers. [5marks]
(c) Copy the following table into your answer script and complete it for each iteration of the
outer loop (loop using k) for the problem scenario given below to carry out a desk-check
of the code given above.
Variable initially After
iteration
1
After
iteration
2
After
iteration
3
After
iteration
4
…
Array d[] 12,25,9,2,
20,15,8
size 7
k 1
d[k] 25
i NA
d[i] NA
Problem Scenario:
array[]
12 25 9 2 20 15 8
[10 Marks]
Question 3 - 20 Marks
(a) Show diagrammatically, the operation of a queue implemented via a circular array
assuming the array size to be 8. Draw diagrams to show the status of the queue for the
following, clearly indicating the position of the head/front and tail/rear.
i. empty queue
ii. after enqueueing 4 items; 12, 23, 8 and 15
iii. full queue [6 Marks]
(b) Suggest a method to differentiate an empty queue (in section (a) above) from a full
queue by comparing the values of head and tail. [5 Marks]
(c) Implement 3 functions, including either enqueue() or dequeue(), of the queue
specification given below. Utilize your suggestion in part (b) above. [9 Marks]
struct queue { int head, tail;
int data[size]; };
int enqueue(struct queue *q, int item);
int dequeue(struct queue*q);
int init(struct queue* q); // set head and tail
int full(struct queue* q); // return 1 if full
int empty(struct queue* q); // return 1 if empty
Question 4 - 20 Marks
Following incomplete code segment intends to implement the linear search algorithm.
int lsearch(float data[], int size, float key){
int found = 0;
int position = –1;
int index = 0;
(a) Complete the above code to using appropriate syntax. [6 marks]
(b) Write down a comment line you would include in the above code against each line to
illustrate the function of each line or statement. You do not have to copy the code –
just put the line number and your comment in your answer script. [4 marks]
Following lines were extracted from a typical linked list implementation prototype in C.
// data structure for a node
struct node { float data;
struct node* next;};
//creates a node with data value (item) & returns the node address
struct node* makeNode(float item);
// add a new node to the head
struct node* addHead(struct node** list, float item);
// add a new node to the tail
struct node* addTail(struct node** list, float item);
(c) Write code for the above three functions to derive the linked list implementation.
[10 marks]
Question 5 - 20 Marks
(a) Draw a binary search tree (BST) generated by inserting the following items in the given
order.
54, 15, 12, 64, 51, 9, 85, 15, 24, 3 [6 Marks]
(b) Draw the sequence of items you process, if the BST is traversed by,
i. pre-order,
ii. in-order,
iii. post-order, tree walking methods. [6 marks]
(c) Write down a node structure in C, suitable to implement the above BST. [2 marks]
(d) Write a C function to return the minimum value stored in a BST. [4 Marks]
(e) Explain the use of tree data structure in a computer application. [2 Marks]

More Related Content

What's hot

Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.organnaunivedu
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABPranoti Doke
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Hossain Md Shakhawat
 
Digital logic design1
Digital logic design1Digital logic design1
Digital logic design1jntuworld
 
Lumpkin Graphing functions
Lumpkin Graphing functionsLumpkin Graphing functions
Lumpkin Graphing functionsrenialumpkin
 
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPEREC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPERVISHNUPRABHANKAIMAL
 
Data Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple GraphsData Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple GraphsRsquared Academy
 
Queue implementation
Queue implementationQueue implementation
Queue implementationRajendran
 
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...Mumbai B.Sc.IT Study
 

What's hot (19)

Implementation
ImplementationImplementation
Implementation
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.org
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLAB
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
 
X10707 (me8691)
X10707 (me8691)X10707 (me8691)
X10707 (me8691)
 
chapter-8.ppt
chapter-8.pptchapter-8.ppt
chapter-8.ppt
 
Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
 
Data Structures- Hashing
Data Structures- Hashing Data Structures- Hashing
Data Structures- Hashing
 
Digital logic design1
Digital logic design1Digital logic design1
Digital logic design1
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Lumpkin Graphing functions
Lumpkin Graphing functionsLumpkin Graphing functions
Lumpkin Graphing functions
 
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPEREC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
EC202 SIGNALS & SYSTEMS PREVIOUS QUESTION PAPER
 
Data Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple GraphsData Visualization With R: Learn To Combine Multiple Graphs
Data Visualization With R: Learn To Combine Multiple Graphs
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Graphing functions
Graphing functionsGraphing functions
Graphing functions
 
Queue
QueueQueue
Queue
 
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
[Question Paper] Introduction To C++ Programming (Revised Course) [January / ...
 
Quiz 10 cp_sol
Quiz 10 cp_solQuiz 10 cp_sol
Quiz 10 cp_sol
 
Ch3
Ch3Ch3
Ch3
 

Similar to Doc 20180130-wa0004-1

Computer science ms
Computer science msComputer science ms
Computer science msB Bhuvanesh
 
Computer Science Sample Paper 2
Computer Science Sample Paper 2Computer Science Sample Paper 2
Computer Science Sample Paper 2kvs
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen TatarynovFwdays
 
Data structure manual
Data structure manualData structure manual
Data structure manualsameer farooq
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917lakshmi r
 
CS Sample Paper 1
CS Sample Paper 1CS Sample Paper 1
CS Sample Paper 1kvs
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
 
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfwasemanivytreenrco51
 
Vtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papersVtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papersmegharajk
 
09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structuresjntuworld
 
Ds important questions
Ds important questionsDs important questions
Ds important questionsLavanyaJ28
 

Similar to Doc 20180130-wa0004-1 (20)

Computer science ms
Computer science msComputer science ms
Computer science ms
 
6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...
 
Computer Science Sample Paper 2
Computer Science Sample Paper 2Computer Science Sample Paper 2
Computer Science Sample Paper 2
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
 
Data structure manual
Data structure manualData structure manual
Data structure manual
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917
 
CS Sample Paper 1
CS Sample Paper 1CS Sample Paper 1
CS Sample Paper 1
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
7th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
 
Bcsl 033 solve assignment
Bcsl 033 solve assignmentBcsl 033 solve assignment
Bcsl 033 solve assignment
 
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdf
 
Vtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papersVtu cs 7th_sem_question_papers
Vtu cs 7th_sem_question_papers
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
8th Semester (June; July-2015) Computer Science and Information Science Engin...
8th Semester (June; July-2015) Computer Science and Information Science Engin...8th Semester (June; July-2015) Computer Science and Information Science Engin...
8th Semester (June; July-2015) Computer Science and Information Science Engin...
 
09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures
 
FSOFT - Test Java Exam
FSOFT - Test Java ExamFSOFT - Test Java Exam
FSOFT - Test Java Exam
 
Adobe
AdobeAdobe
Adobe
 
CS_PQMS.pdf
CS_PQMS.pdfCS_PQMS.pdf
CS_PQMS.pdf
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
5th Semester (June; July-2015) Computer Science and Information Science Engin...
5th Semester (June; July-2015) Computer Science and Information Science Engin...5th Semester (June; July-2015) Computer Science and Information Science Engin...
5th Semester (June; July-2015) Computer Science and Information Science Engin...
 

More from HarithaRanasinghe (20)

Session12 pointers
Session12 pointersSession12 pointers
Session12 pointers
 
Session11 single dimarrays
Session11 single dimarraysSession11 single dimarrays
Session11 single dimarrays
 
Session09 multi dimarrays
Session09 multi dimarraysSession09 multi dimarrays
Session09 multi dimarrays
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Session06 functions
Session06 functionsSession06 functions
Session06 functions
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
 
Session04 selection structure_b
Session04 selection structure_bSession04 selection structure_b
Session04 selection structure_b
 
Session04 selection structure_a
Session04 selection structure_aSession04 selection structure_a
Session04 selection structure_a
 
Session03 operators
Session03 operatorsSession03 operators
Session03 operators
 
Session02 c intro
Session02 c introSession02 c intro
Session02 c intro
 
Session01 basics programming
Session01 basics programmingSession01 basics programming
Session01 basics programming
 
Program flow charts
Program flow chartsProgram flow charts
Program flow charts
 
Sad -sample_paper
Sad  -sample_paperSad  -sample_paper
Sad -sample_paper
 
Sad sample paper - mcq answers
Sad   sample paper - mcq answersSad   sample paper - mcq answers
Sad sample paper - mcq answers
 
Paper
PaperPaper
Paper
 
Model questions
Model questionsModel questions
Model questions
 
Model paper algorithms and data structures
Model paper  algorithms and data structuresModel paper  algorithms and data structures
Model paper algorithms and data structures
 
Doc 20180208-wa0001
Doc 20180208-wa0001Doc 20180208-wa0001
Doc 20180208-wa0001
 
Doc 20180130-wa0005
Doc 20180130-wa0005Doc 20180130-wa0005
Doc 20180130-wa0005
 
Doc 20180130-wa0004
Doc 20180130-wa0004Doc 20180130-wa0004
Doc 20180130-wa0004
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Doc 20180130-wa0004-1

  • 1. National School of Business Management Algorithms and Data Structures CS106.3 - 16.2 Examination Time: 03Hrs Answer all Questions Date: 2017 Question 1 – 20 Marks (a) What is asymptotic analysis in the context of evaluation of Algorithms? [5 Marks] (b) Simplify the following Big-O expressions [10 Marks] i. O(10n4-n2-10) ii. O(2n3+102n) * O(n) iii. O(n2) + O(5*log(n)) iv. O(n2) * O(5*log(n)) v. n2*O(n2) (c) Giving reasons, evaluate the time complexity of the following function. [5 Marks] int swapping; do { for(i=0,swapping=0;i<size-1;i++) if(data[i]>data[i+1]) { temp=data[i]; data[i]=data[i+1]; data[i+1]=temp; swapping=1; } } while(swapping) Question 2 - 20 Marks Following loop implements the insertion sort algorithm. 1 for(k=1; k<size; k++){ 2 for(i=0; i<k && d[i]<=d[k]; i++); 3 temp=d[k]; 4 for(l=k;l>i;l--) d[l]=d[l-1]; 5 d[i]=temp; 6 }
  • 2. (a) Write a complete C function to implement the insertion sort algorithm. [5 marks] (b) Write down a comment line for each and every line in the above C function in part (a). If necessary number the lines in the C function and write the comments separately with the line numbers. [5marks] (c) Copy the following table into your answer script and complete it for each iteration of the outer loop (loop using k) for the problem scenario given below to carry out a desk-check of the code given above. Variable initially After iteration 1 After iteration 2 After iteration 3 After iteration 4 … Array d[] 12,25,9,2, 20,15,8 size 7 k 1 d[k] 25 i NA d[i] NA Problem Scenario: array[] 12 25 9 2 20 15 8 [10 Marks] Question 3 - 20 Marks (a) Show diagrammatically, the operation of a queue implemented via a circular array assuming the array size to be 8. Draw diagrams to show the status of the queue for the following, clearly indicating the position of the head/front and tail/rear. i. empty queue ii. after enqueueing 4 items; 12, 23, 8 and 15 iii. full queue [6 Marks] (b) Suggest a method to differentiate an empty queue (in section (a) above) from a full queue by comparing the values of head and tail. [5 Marks] (c) Implement 3 functions, including either enqueue() or dequeue(), of the queue specification given below. Utilize your suggestion in part (b) above. [9 Marks]
  • 3. struct queue { int head, tail; int data[size]; }; int enqueue(struct queue *q, int item); int dequeue(struct queue*q); int init(struct queue* q); // set head and tail int full(struct queue* q); // return 1 if full int empty(struct queue* q); // return 1 if empty Question 4 - 20 Marks Following incomplete code segment intends to implement the linear search algorithm. int lsearch(float data[], int size, float key){ int found = 0; int position = –1; int index = 0; (a) Complete the above code to using appropriate syntax. [6 marks] (b) Write down a comment line you would include in the above code against each line to illustrate the function of each line or statement. You do not have to copy the code – just put the line number and your comment in your answer script. [4 marks] Following lines were extracted from a typical linked list implementation prototype in C. // data structure for a node struct node { float data; struct node* next;}; //creates a node with data value (item) & returns the node address struct node* makeNode(float item); // add a new node to the head struct node* addHead(struct node** list, float item); // add a new node to the tail struct node* addTail(struct node** list, float item); (c) Write code for the above three functions to derive the linked list implementation. [10 marks]
  • 4. Question 5 - 20 Marks (a) Draw a binary search tree (BST) generated by inserting the following items in the given order. 54, 15, 12, 64, 51, 9, 85, 15, 24, 3 [6 Marks] (b) Draw the sequence of items you process, if the BST is traversed by, i. pre-order, ii. in-order, iii. post-order, tree walking methods. [6 marks] (c) Write down a node structure in C, suitable to implement the above BST. [2 marks] (d) Write a C function to return the minimum value stored in a BST. [4 Marks] (e) Explain the use of tree data structure in a computer application. [2 Marks]