Professional Documents
Culture Documents
A. Instructions:
(Please include the following: 1. Screenshots of the output from MindTap, 2. Screenshots of the IDE from
MindTap, and 3. The source code from MindTap.)
Screenshot of Output
(Insert images here from the output of the console window of MindTap)
Screenshot of Codes
(Insert images here)
Screenshot of your code in MindTap. Use the snipping tool to properly capture the codes.
Resize the image properly so that it fits in the table. Use a whole page for this part if necessary.
Source Code
(insert Source Code here)
Paste the actual code from MindTap here. Use the following format: Courier New 9
#include <iostream>
int main() {
cout << "Hello World" << endl;
return 0;
}
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 1
Laboratory Report 4
GRAPHS, SEARCHING, AND SORTING
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 2
Laboratory Report 4
GRAPHS, SEARCHING, AND SORTING
B. Coding Exercises:
1. Write a program that outputs the shortest distance from a given node to every other node in the graph.
Screenshot of Output
Screenshot of Codes
Source Code
main.cpp
#include <iostream>
#include "searchSortAlgorithms.h"
int main() {
const int length = 7;
int sortedArray[length] = {1, 3, 5, 7, 9, 11, 13};
int itemToSearch;
cout << "Enter the item to search: ";
cin >> itemToSearch;
if (result == -1) {
cout << "Item not found in the array." << endl;
} else {
cout << "Item found at index " << result << "." << endl;
}
return 0;
}
// SEARCH_SORT_ALGORITHMS_H
#ifndef SEARCH_SORT_ALGORITHMS_H
#define SEARCH_SORT_ALGORITHMS_H
template<class elemType>
inline int seqOrdSearch(const elemType list[], int length, const elemType& item)
{
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 3
Laboratory Report 4
GRAPHS, SEARCHING, AND SORTING
int index = 0;
#endif // SEARCH_SORT_ALGORITHMS_H
2. Write a program to test the function you designed in Exercise 3. Note: Have the function,seqOrdSearch,
return -1 if the item is not found in the list. (return the index of the item if found).
Screenshot of Output
Screenshot of Codes
Source Code
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 4
Laboratory Report 4
GRAPHS, SEARCHING, AND SORTING
C. Findings, Observations, and Comments:
Guiding Questions :
1. Did you solve the coding exercise/s?
2. Are there any difficulties during coding or set-up that you encountered?
3. What are your findings, observations, and comments in the coding exercise?
I’m able to solve the lab 4-2 but the lab 4-1 I had a hard time solving it and I couldn’t find the error.
The main exercise is hard by it self but I’m able to solve it and got 100%. I learned the sort algorithm
that we discussed last meeting and I’m able to apply it to this laboratory exercise.
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 5
Laboratory Report 4
GRAPHS, SEARCHING, AND SORTING
D. Score Sheet
SCORE:
CHECKED
Signature
Rating
Date
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 6