Giter VIP home page Giter VIP logo

linked-lists-problems's Introduction

linked-lists-problems

Solutions using pointer algorithms in C for common Linked Lists problems.

The problems use the C language syntax, so they require a basic understanding of C and its pointer syntax. The emphasis is on the important concepts of pointer manipulation and linked list algorithms rather than the features of the C language.

A base class - linkedlist.c, with basic utitlity functions, is defined in /libs. All of the linked list code in this document uses the "classic" singly linked list structure:

  • A single head pointer points to the first node in the list. Each node contains a single .next pointer to the next node.
  • The .next pointer of the last node is NULL. The empty list is represented by a NULL head pointer.
  • All of the nodes are allocated in the heap.

For a few of the problems, the solutions present the temporary "dummy node" or a "reference pointer" variation. They use memory in unusual ways, so they are a nice way to see if you really understand what's going on ๐Ÿ˜

The problems roughly in order of difficulty:

  1. Count occurences of value i in linked list - Count.c
  2. Remove head and return value - Pop.c
  3. Get Nth value from linked list - GetNth.c
  4. Move head from source list to destination - moveHead.c
  5. Reverse a list - ReverseList.c
  6. Delete linked list and free memory - DeleteList.c
  7. Insert value at position N in linked list - InsertNth.c
  8. Recursively reverse a list - RecursiveReverse.c

linked-lists-problems's People

Contributors

muffpy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.