LAB1
LAB1
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 1
POINTERS, LINKED LISTS, AND STACKS
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 2
Laboratory Report 1
POINTERS, LINKED LISTS, AND STACKS
B. Coding Exercises:
1. The function retrieveAt of the class arrayListType is written as a void function. Rewrite this function so that
it is written as a value returning function, returning the required item. If the location of the item to be returned
is out of range, use the assert function to terminate the program. Also, write a program to test your function.
Use the class unorderedArrayListType to test your function.
Screenshot of Output
Screenshot of Codes
Source Code
#include <iostream>
#include "unorderedArrayListType.h"
int main() {
unorderedArrayListType Listed(8);
int num;
int location;
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 3
Laboratory Report 1
POINTERS, LINKED LISTS, AND STACKS
for (int i = 0; i < 8; i++) {
cin >> num;
Listed.insertEnd(num);
}
Listed.print();
cout << endl;
return 0;
}
2. Write a program to test various operations of the class doublyLinkedList. Your program should accept a list
of integers from a user and use the doubleLinkedList class to output the following:
1. The list in ascending order.
2. The list in descending order.
3. The list after deleting a number.
4. A message indicating if a number is contained in the list.
5. Output of the list after using the copy constructor.
6. Output of the list after using the assignment operator.
Screenshot of Output
Screenshot of Codes
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 4
Laboratory Report 1
POINTERS, LINKED LISTS, AND STACKS
Source Code
#include <iostream>
#include "doublyLinkedList.h"
using namespace std;
void TCC(doublyLinkedList<int> list);
int main() {
doublyLinkedList<int> DataList, test;
int num;
cout << "Enter a list of positive integers ending with -999: " << endl;
cin >> num;
while(num != -999){
DataList.insert(num);
cin >> num;
}
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 5
Laboratory Report 1
POINTERS, LINKED LISTS, AND STACKS
DataList.deleteNode(num);
cout << "List after deleting " << num << " : ";
DataList.print();
cout << endl;
if(DataList.search(num)){
cout << num << " found in the list." << endl;
}
else {
cout << num << " is not in the list." << endl;
}
TCC(DataList);
cout << "intList: ";
DataList.print();
cout << endl;
test.destroy()
test = DataList;
cout << "temp: ";
DataList.print();
return 0;
}
3. Write a program that takes as input an arithmetic expression followed by a semicolon ;. The program
outputs whether the expression contains matching grouping symbols. For example, the arithmetic
expressions {25 + (3 – 6) * 8} and 7 + 8 * 2 contain matching grouping symbols. However, the expression 5 +
{(13 + 7) / 8 - 2 * 9 does not contain matching grouping symbols.
If the expression contains matching grouping symbols, the program output should contain the following text:
Expression has matching grouping symbol. If the expression does not contain matching grouping symbols,
the program output should contain the following text: Expression does not have matching grouping symbols.
Screenshot of Output
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 6
Laboratory Report 1
POINTERS, LINKED LISTS, AND STACKS
Screenshot of Codes
Source Code
#include <iostream>
#include "myStack.h"
int main() {
string expression;
if (hasMatchingGroupingSymbols(expression)) {
cout << "Expression has matching grouping symbols" << endl;
}
else {
cout << "Expression does not have matching grouping symbols" << endl;
}
return 0;
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 8
Laboratory Report 1
POINTERS, LINKED LISTS, AND STACKS
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?
(Please type your findings, observations, and comments according to the guide questions in a paragraph
format.)
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page | 9
Laboratory Report 1
POINTERS, LINKED LISTS, AND STACKS
D. Score Sheet
SCORE:
CHECKED
Signature
Rating
Date
_________________________________________________________________________________________________
CPE104L Data Structures and Algorithms
School of Electrical, Electronics, and Computer Engineering Page |
10