Socket
Book a DemoInstallSign in
Socket

linked_list_sourav

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linked_list_sourav

0.1.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Linked List

Gem Version This is linked list implementation both singly and doubly in ruby. Its main purpose is demonstration.

Usage

  require "linked_list_sourav"
  list = LinkedList::Singly.new(1) # intializes a new list
  list.head # returns head node
  list.add(2) # adds a new node
  3.upto(20) { |data| list.add(data)}
  list.find(10) # finds and return the node that contains data as 10
  list.delete(6)  # removes the node that contain 6 as data
  list.add_a([21, 22, 23, 24]) #adds array members directly
  list = LinkedList::Singly.new([1, 2, 3, 4]) # intialize with an array
  list.parse # prints all the data from the list
  list.to_a # prints an array of all data
  list.to_s #prints an string of all data
  list.no_of_nodes # returns no of nodes present in the linked list

  ### The same for Doubly Linked list ###

  list = LinkedList::Doubly.new(1) # intializes a new list
  list.head # returns head node
  list.add(2) # adds a new node
  3.upto(20) { |data| list.add(data)}
  list.find(10) # finds and return the node that contains data as 10
  list.delete(6)  # removes the node that contain 6 as data
  list = LinkedList::Doubly.new([1, 2, 3, 4]) # intialize with an array
  list.parse # prints all the data from the list
  list.to_a # prints an array of all data
  list.to_s #prints an string of all data

FAQs

Package last updated on 17 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.