Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

linked-list

How is LinkedList’s add(int, E) of O(1) complexity?

December 16, 2023 by Tarik

This is because the article that you are reading considered “getting to that index” as a separate operation. The article assumes that you are already at the index you wish to perform add(int, E). To conclude: Insert or Remove operation = O(1) Finding node at nth index = O(n)

Categories linked-list Tags big-o, java, linked-list, time-complexity Leave a comment

Finding loop in a singly linked-list

March 6, 2023 by Tarik

You can detect it by simply running two pointers through the list, this process is known as the tortoise and hare algorithm after the fable of the same name: First off, check if the list is empty (head is null). If so, no cycle exists, so stop now. Otherwise, start the first pointer tortoise on … Read more

Categories linked-list Tags linked-list Leave a comment

Why is inserting in the middle of a linked list O(1)?

November 15, 2022 by Tarik

You are correct, the article considers “Indexing” as a separate operation. So insertion is itself O(1), but getting to that middle node is O(n).

Categories linked-list Tags big-o, linked-list Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa