Selahattin's Blog

Data Structures

It was published 13 days ago
It was updated a few seconds ago

Data structure is a format to storage, manage, organize the data.


Stack stores the data in linear order. The order could be FIFO (First in First Out) or LIFO (Last in First Out).

Stacks could have these functions on it:

  • push: to add new item to end of stack
  • pop: to remove the last item of stack
  • peek: to display the last item of stack
  • length: to display how many items the stack has.


Set is kind of array except there no duplicated items. And there is no any particular order.

Set has following methods commonly:

  • has: to determine whether the item is inside the set
  • values: to return all the values the item has
  • add: to add new items to the set but first, it will check the item whether if it is exists already
  • remove to remove the item from the set
  • size to display how many items the set has
  • union to return combination of two sets without duplication as a new set
  • intersection to return the insersection of two sets as a new set
  • difference to return the difference of two sets as a new set
  • subset to test if the set is a subset of the other set or not


…. 19:28