data-structures-and-algorithms-java

View project on GitHub

Singly Linked List

The LinkedList class is a collection which can contain many objects of the same type and has many methods so you can add items, change items, remove items and clear the list

user have a Linked List and we want to create methods to : add item at the end of the list // input: integer //output LinkedList give 2 value first one it’s the value I want to add the value before it and the second one it’s the value  //input: two integer value //output LinkedList give 2 value first one it’s the value I want to add the value after it and the second one it’s the value //input: two integer value //output LinkedList

Challenge

Make a Node class and linked list class that includes 3 methodes ansert, includes and toString

Approach & Efficiency

I started with make a node class then the linked list and finally test the code

O()

Method Time complixty space complixty
insert O(1) O(1)
includes O(n) O(1)
toString O(n) O(n)
kth o(n) O(1)
zip o(n) O(n)

API

  • insert that take an integer and add it to linked list
  • includes that take an integer and return boolean if it is in array return true if not false
  • toString that return a string contain all object value

white board

  • this white boaard for class06

white board

  • this white boaard for class07

    white board

  • this white boaard for class08

    white board