LinkedListLabReport
LinkedListLabReport
Gentry-Kolen
COMSC-210
9 February 2020
Problem: Identify a problem that can efficiently be solved with linked lists and
Discussion:
Solution/Program Description: This program uses a singly linked list to store very large
integers that may be larger than what the primitive data types of C++ can normally
handle. It has functions to add and remove digits, as well as functions to peek at digits,
Pseudocode:
}
size++;
}
int getSize(){
return size;
}
};
class BigNumber {
private:
LinkedList<int> bigNumberList;
bool isNegative;
public:
BigNumber(){
isNegative = false;
}
void addDigit(int n){
bigNumberList.addLast(n);
}
int peekLastDigit(){
return bigNumberList.peekLast();
}
int peekFirstDigit(){
return bigNumberList.peekFirst();
}
int removeLastDigit(){
return bigNumberList.removeLast();
}
int removeFirstDigit(){
return bigNumberList.removeFirst();
}
int getSize(){
return bigNumberList.getSize();
}
void display(){
if(isNegative){
cout << "-";
bigNumberList.displayList();
}else
bigNumberList.displayList();
}
int getNumSize(){
return bigNumberList.getSize();
}
void setNegative(){
isNegative = true;
}
void setPositive(){
isNegative = false;
}
bool getSign(){
return isNegative;
}
};
bigNum.removeFirstDigit();
bigNum.removeLastDigit();
cout << endl << "After removing last digit: ";
bigNum.display();
return 0;
}
Major Implementation Issues: The biggest difficulty in implementing this program was
the linked list. More specifically, the remove methods were especially hard since they
Screenshots:
Known Bugs/Errors:
• When given a non-integer input, the program terminates with an uncaught exception of
• When the number is too big, say past 200 digits, the program runs extremely slowly.
Sometimes, with numbers sufficiently past 200 digits, the program simply doesn’t run
Lessons Learned:
• What went well during this lab included the successful implementation of a working
is more versatile and one that contains more advanced functions to do more.