SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Data Structures and Algorithm Analysis
1. How much memory will the following structures take up?
Hint: int takes 4 bytes, float takes 4 bytes, char takes 1 byte. – 9
points
a. struct Structure1 {int a,b,c,d,e[10]; float f;};
b. struct Structure2 {int a[12]; float b[5];};
c. struct Structure3 {char a[10][12][4], b[5][5], c[10];};
2. Show the steps when sorting (smallest to largest) the
following arrays of numbers using
selection sort
i.e. every time a swap occurs, show what the current state of
the array looks like, including the final sorted array. – 12 points
a. [10, 2, 5, 8, 9, 1, 4, 7]
b. [7, 1, 3, 2, 5, 4, 8, 12, 9]
c. [8, 7, 6, 5, 4, 3, 2, 1]
d. [5, 3, 8, 1, 9, 4, 2, 6]
3. Big-O: What is meant by f(n) = O(g(n))? Give the definition
and then explain what it means in your own terms. – 5 points
4. Big-Omega: What is meant by f(n) = Ω(g(n))? Give the
definition and then explain what it means in your own terms. –
5 points
5. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
6. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
7. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
8. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
9. Show that
, make sure you use the definition and justify the inequalities
and constants used. - 4 points
10. What principle governs how you add/remove elements in a
stack? Spell it out and briefly explain. - 4 points
11. Briefly describe an application of a stack. - 4 points
12. What principle governs how you add/remove elements in a
queue? Spell it out and briefly explain. - 4 points
13. Briefly describe an application of a queue. - 4 points
Consider the following graph (pseudocode for BFS and DFS
given on page 9):
14. Write the order in which the nodes would be visited in when
doing a
breadth first search (BFS)
traversal starting at
node 4
. Also, write the distances from 4 to every other node. - 6 points
15. Write the order in which the nodes would be visited in when
doing a
breadth first search (BFS)
traversal starting at
node 5
. Also, write the distances from 5 to every other node. - 6 points
Same graph (for your convenience):
16. Write the order in which the nodes would be visited in when
doing a
depth first search (DFS)
traversal starting at
node 4 (order discovered or order off the stack)
. - 6 points
17. Write the order in which the nodes would be visited in when
doing a
depth first search (DFS)
traversal starting at
node 5 (order discovered or order off the stack)
. - 6 points
18. Give the definition of a graph. - 5 points
19. Give the definition of a tree (from graph theory). - 4 points
BFS Pseudocode (for graph with n vertices):
Input: grapharray[n][n], source
queue Q
int distance[n] (array to keep track of nodes distances (from
source), all values set to -1 except source which is set to 0
i.e. -1 = not visited)
Q.push(source)
while(Q is not empty)
v = Q.front
Q.pop()
for each neighbor w of v
if distance[w] = -1
print w
distance[w] = distance[v]+1
Q.push(w)
end if
end for
end while
DFS Pseudocode (for graph with n vertices):
Input: grapharray[n][n], source
stack S
int visited[n] (array to keep track of nodes visited, all values
set to 0 except source which is set to 1 i.e. 0 = not visited, 1
= visited)
S.push(source)
while(S is not empty)
v = S.top
S.pop()
for each neighbor w of v
if visited[w] = 0
print w
visited[w] = 1
S.push(w)
end if
end for
end while
Bonus (4 points): Show
all
of the steps (splitting and merging) when using mergesort to
sort (smallest to largest) the following array (they are the
numbers 1 through 16):
[16, 1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]
Bonus (2 points): describe how you could implement a queue
using 2 stacks.
Bonus (4 points) Draw the binary search tree that would be
constructed by inserting the following values in the exact order
given (starting with an empty tree i.e. first value will be the
first node in the tree): -
a. Binary Search Tree A: 8, 9, 2, 7, 1, 10, 3, 5, 6, 4
b. Binary Search Tree B: 10, 7, 9, 12, 4, 2, 5, 3, 1, 14, 11, 19,
13, 18, 20

Weitere ähnliche Inhalte

Ähnlich wie Data Structures and Algorithm Analysis1. How much memory w.docx

bfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptxbfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptxsaurabhpandey679381
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxwhittemorelucilla
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsSigSegVSquad
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Shuvongkor Barman
 
hospital management
hospital managementhospital management
hospital managementguestbcbbb5c
 
lecture 17
lecture 17lecture 17
lecture 17sajinsc
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxmariuse18nolet
 
Breadth first search (Bfs)
Breadth first search (Bfs)Breadth first search (Bfs)
Breadth first search (Bfs)Ishucs
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questionsGradeup
 

Ähnlich wie Data Structures and Algorithm Analysis1. How much memory w.docx (20)

bfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptxbfs tree searching ,sortingUntitled presentation.pptx
bfs tree searching ,sortingUntitled presentation.pptx
 
Graphs
GraphsGraphs
Graphs
 
Graph
GraphGraph
Graph
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
Graphs bfs dfs
Graphs bfs dfsGraphs bfs dfs
Graphs bfs dfs
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
 
LEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdfLEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdf
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
hospital management
hospital managementhospital management
hospital management
 
lecture 17
lecture 17lecture 17
lecture 17
 
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
 
Graphs
GraphsGraphs
Graphs
 
Parallel search
Parallel searchParallel search
Parallel search
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docx
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
 
Breadth first search (Bfs)
Breadth first search (Bfs)Breadth first search (Bfs)
Breadth first search (Bfs)
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questions
 
Graph
GraphGraph
Graph
 

Mehr von randyburney60861

Delusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docxDelusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docxrandyburney60861
 
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docxDemand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docxrandyburney60861
 
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docxDeloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docxrandyburney60861
 
DELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docxDELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docxrandyburney60861
 
Deliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docxDeliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docxrandyburney60861
 
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docxDeliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docxrandyburney60861
 
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docxDeliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docxrandyburney60861
 
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docxDeliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docxrandyburney60861
 
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docxDeliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docxrandyburney60861
 
Deliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docxDeliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docxrandyburney60861
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docxrandyburney60861
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docxrandyburney60861
 
DEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docxDEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docxrandyburney60861
 
Definition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docxDefinition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docxrandyburney60861
 
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docxDefinition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docxrandyburney60861
 
Definition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docxDefinition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docxrandyburney60861
 
Definition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docxDefinition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docxrandyburney60861
 
DEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docxDEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docxrandyburney60861
 
Defining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docxDefining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docxrandyburney60861
 
Define      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docxDefine      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docxrandyburney60861
 

Mehr von randyburney60861 (20)

Delusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docxDelusional DisordersPakistani hought ProcessesBACKGROUND.docx
Delusional DisordersPakistani hought ProcessesBACKGROUND.docx
 
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docxDemand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
Demand, Supply, and the Market ProcessGWARTNEY – STROUP .docx
 
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docxDeloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
Deloitte’s 2020 Global Blockchain SurveyFrom promise to re.docx
 
DELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docxDELL COMPANY’ Application of the accounting theories on the comp.docx
DELL COMPANY’ Application of the accounting theories on the comp.docx
 
Deliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docxDeliverable Length10–15 slides not including title and refere.docx
Deliverable Length10–15 slides not including title and refere.docx
 
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docxDeliverable 6 - Using Business VisualsCompetencyExamine and de.docx
Deliverable 6 - Using Business VisualsCompetencyExamine and de.docx
 
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docxDeliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
Deliverable 5 - Hypothesis Tests for Two SamplesCompetencyForm.docx
 
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docxDeliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
Deliverable 5 - Proposed HR Initiatives PresentationAssignme.docx
 
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docxDeliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
Deliverable 4 - Diversity and Inclusion PolicyAssignment Con.docx
 
Deliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docxDeliverable 4 - Global Environment ChallengesCompetencyC.docx
Deliverable 4 - Global Environment ChallengesCompetencyC.docx
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Com.docx
 
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docxDeliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
Deliverable 03 - Humanities (Test-Out Sophia Replacement)Compete.docx
 
DEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docxDEFINITION a brief definition of the key term followed by t.docx
DEFINITION a brief definition of the key term followed by t.docx
 
Definition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docxDefinition of HIVAIDS. What are the symptoms and general characteri.docx
Definition of HIVAIDS. What are the symptoms and general characteri.docx
 
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docxDefinition of Ethos and How to Use it1. Trustworthiness
Does y.docx
Definition of Ethos and How to Use it1. Trustworthiness
Does y.docx
 
Definition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docxDefinition Multimodal refers to works that use a combination .docx
Definition Multimodal refers to works that use a combination .docx
 
Definition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docxDefinition Argument Essay AssignmentGoal Write a 1,500.docx
Definition Argument Essay AssignmentGoal Write a 1,500.docx
 
DEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docxDEFINITION a brief definition of the key term followed by the APA r.docx
DEFINITION a brief definition of the key term followed by the APA r.docx
 
Defining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docxDefining Privacy in Employee Health ScreeningCases Ethical .docx
Defining Privacy in Employee Health ScreeningCases Ethical .docx
 
Define      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docxDefine      diversity” and inclusion” as applied to your pre.docx
Define      diversity” and inclusion” as applied to your pre.docx
 

Kürzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Kürzlich hochgeladen (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

Data Structures and Algorithm Analysis1. How much memory w.docx

  • 1. Data Structures and Algorithm Analysis 1. How much memory will the following structures take up? Hint: int takes 4 bytes, float takes 4 bytes, char takes 1 byte. – 9 points a. struct Structure1 {int a,b,c,d,e[10]; float f;}; b. struct Structure2 {int a[12]; float b[5];}; c. struct Structure3 {char a[10][12][4], b[5][5], c[10];}; 2. Show the steps when sorting (smallest to largest) the following arrays of numbers using selection sort i.e. every time a swap occurs, show what the current state of the array looks like, including the final sorted array. – 12 points a. [10, 2, 5, 8, 9, 1, 4, 7] b. [7, 1, 3, 2, 5, 4, 8, 12, 9] c. [8, 7, 6, 5, 4, 3, 2, 1] d. [5, 3, 8, 1, 9, 4, 2, 6] 3. Big-O: What is meant by f(n) = O(g(n))? Give the definition and then explain what it means in your own terms. – 5 points 4. Big-Omega: What is meant by f(n) = Ω(g(n))? Give the definition and then explain what it means in your own terms. – 5 points
  • 2. 5. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 6. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 7. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 8. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 9. Show that , make sure you use the definition and justify the inequalities and constants used. - 4 points 10. What principle governs how you add/remove elements in a stack? Spell it out and briefly explain. - 4 points 11. Briefly describe an application of a stack. - 4 points 12. What principle governs how you add/remove elements in a queue? Spell it out and briefly explain. - 4 points 13. Briefly describe an application of a queue. - 4 points Consider the following graph (pseudocode for BFS and DFS given on page 9): 14. Write the order in which the nodes would be visited in when
  • 3. doing a breadth first search (BFS) traversal starting at node 4 . Also, write the distances from 4 to every other node. - 6 points 15. Write the order in which the nodes would be visited in when doing a breadth first search (BFS) traversal starting at node 5 . Also, write the distances from 5 to every other node. - 6 points Same graph (for your convenience): 16. Write the order in which the nodes would be visited in when doing a depth first search (DFS) traversal starting at node 4 (order discovered or order off the stack) . - 6 points 17. Write the order in which the nodes would be visited in when doing a depth first search (DFS) traversal starting at node 5 (order discovered or order off the stack) . - 6 points 18. Give the definition of a graph. - 5 points 19. Give the definition of a tree (from graph theory). - 4 points
  • 4. BFS Pseudocode (for graph with n vertices): Input: grapharray[n][n], source queue Q int distance[n] (array to keep track of nodes distances (from source), all values set to -1 except source which is set to 0 i.e. -1 = not visited) Q.push(source) while(Q is not empty) v = Q.front Q.pop() for each neighbor w of v if distance[w] = -1 print w distance[w] = distance[v]+1 Q.push(w) end if end for end while
  • 5. DFS Pseudocode (for graph with n vertices): Input: grapharray[n][n], source stack S int visited[n] (array to keep track of nodes visited, all values set to 0 except source which is set to 1 i.e. 0 = not visited, 1 = visited) S.push(source) while(S is not empty) v = S.top S.pop() for each neighbor w of v if visited[w] = 0 print w visited[w] = 1 S.push(w) end if end for end while Bonus (4 points): Show all
  • 6. of the steps (splitting and merging) when using mergesort to sort (smallest to largest) the following array (they are the numbers 1 through 16): [16, 1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8] Bonus (2 points): describe how you could implement a queue using 2 stacks. Bonus (4 points) Draw the binary search tree that would be constructed by inserting the following values in the exact order given (starting with an empty tree i.e. first value will be the first node in the tree): - a. Binary Search Tree A: 8, 9, 2, 7, 1, 10, 3, 5, 6, 4 b. Binary Search Tree B: 10, 7, 9, 12, 4, 2, 5, 3, 1, 14, 11, 19, 13, 18, 20