top() Method returns the last element of the stack. ![]() pop() Method removes the last element of the stack. There are 4 primary operations in the stack as follows: push() Method adds element x to the stack. It should print an error message and return null if the list is empty. Instead of only an Integer Stack, Stack can be of String, Character, or even Float type. It should print an error message and return null if the list is empty.Īnything getLast(): Returns the value stored in the last node in the list. Express, especially at the high level there, what code does. The class Node has a type parameter, but in your class CS2LinkedList you are using it without the type parameter. A good model is to assume the user only sees the. ![]() Documentation Code, especially linkedlist.h lacks documentation. Write an interface that has PUSH, POP, PEEK, isEmpty and implement these methods. Trying to get these 2 methods to work, but I don't have much experience with generics and the concept is confusing a lot.Īnything getFirst(): Returns the value stored in the first node in the list. A function that does something to every node in the link-list Id expect a sizet LinkedListCount (const LinkedList this) to return the list count. Implement STACK ADT using a generic linked list (shown below). Im having an issue inserting a new object into a linked list.
0 Comments
Leave a Reply. |