Skip to content

Add basic singly linked list implementation in both Objective-C and C (typedef struct)#5

Open
ruvalcaba18 wants to merge 4 commits intocareercup:masterfrom
ruvalcaba18:add-objectivec-solutions
Open

Add basic singly linked list implementation in both Objective-C and C (typedef struct)#5
ruvalcaba18 wants to merge 4 commits intocareercup:masterfrom
ruvalcaba18:add-objectivec-solutions

Conversation

@ruvalcaba18
Copy link
Copy Markdown

Summary

This pull request adds a foundational implementation of a singly linked list in two styles:

  • ✅ Object-Oriented: using Objective-C classes (LinkedListNode)
  • ✅ C-style: using typedef struct and manual memory management

These match the patterns and function examples shown in Cracking the Coding Interview, providing support for classic linked list problems.


Objective-C Implementation Highlights

  • LinkedListNode class:
    • appendToTail: – adds a new node to the end of the list
    • deleteNode: – removes the first occurrence of a node with a specific value
    • printList: – utility class method to print the contents of a list

All methods include documentation and mimic common patterns found in the book.


C (typedef struct) Implementation Highlights

  • Struct: LinkedListNode_C_Style
  • Functions:
    • createNode(int value)
    • appendToTail(LinkedListNode_C_Style *head, int value)
    • deleteNode(LinkedListNode_C_Style *head, int value)
    • printList(LinkedListNode_C_Style *head)
    • freeList(LinkedListNode_C_Style *head)

This implementation helps reinforce pointer manipulation, memory handling (malloc / free), and basic data structure fundamentals — perfect for interview preparation in low-level environments.


Motivation

The purpose of this addition is to provide:

  • A dual-style reference (Objective-C and C) for beginners and advanced users
  • A clear base for solving linked list problems such as:
    • Remove Duplicates
    • Delete Middle Node
    • Partition List
    • Detect Loop
    • Reverse List

This aligns directly with Chapter 2 of Cracking the Coding Interview.


Happy to receive feedback or suggestions. Thanks for maintaining this repo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant