Quick Sort In a Linked List | comparison Between Quick and Merge Sort | Pepcoding Solution

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

ความคิดเห็น • 32

  • @shubhs.2803
    @shubhs.2803 2 ปีที่แล้ว +1

    I made it my self without watching this video, because of u sir.
    Your videos helped me to clear my basics and applying correct logic

  • @mastrex
    @mastrex 2 ปีที่แล้ว

    first node ko bhi to pivot index le sakte hai
    tab na length nikalna hai na pivot find karna hai

  • @pulkitgpt1234
    @pulkitgpt1234 3 ปีที่แล้ว

    sir there is one mistake.... we should do - - pivotindex in segregate so that pivot pointer lands on the correct pivot node... this makes the quick sort faster than current solution.

  • @atulbahuguna9357
    @atulbahuguna9357 3 ปีที่แล้ว

    God Level Explanation 🔥🔥Thank You sir

  • @kumarsunny4358
    @kumarsunny4358 3 ปีที่แล้ว +1

    Very well explained sir 👌👌

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว +1

      Thanks for liking and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @mahavirsingh5790
    @mahavirsingh5790 3 ปีที่แล้ว +2

    nice sir

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      Thanks and welcome

  • @ashutoshjha5356
    @ashutoshjha5356 3 ปีที่แล้ว

    awesomely explained

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว +1

      Thankyou
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @rishabhgoyal8110
    @rishabhgoyal8110 2 ปีที่แล้ว +2

    bade miya(SM) bade miya, chote miya(RK) subahn allah!

    • @Pepcoding
      @Pepcoding  2 ปีที่แล้ว +1

      Hope yo like the video.
      visit on nados.pepcoding.com
      yo will find better experience with organised content.
      Don't forget to follow us on Instagram instagram.com/pepcoding/

  • @LegitGamer2345
    @LegitGamer2345 3 ปีที่แล้ว +1

    Awesome !

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      Thank you! Cheers!

  • @amanpreetsinghsetia1524
    @amanpreetsinghsetia1524 3 ปีที่แล้ว

    op video sir 👌👌👌👌!

  • @abhishekkamboj7150
    @abhishekkamboj7150 2 ปีที่แล้ว

    Sir ye tail ko index 1 pe kase return krega ye smaj ni arha hh

    • @Pepcoding
      @Pepcoding  2 ปีที่แล้ว +1

      Post your doubts on nados.pepcoding.com our community will help you out.

  • @kunalkhallar9699
    @kunalkhallar9699 9 หลายเดือนก่อน

    #include
    using namespace std;
    class Node {
    public:
    int data;
    Node *next;
    Node() : next(nullptr) {}
    Node(int d) : data(d), next(nullptr) {}
    };
    class LinkedList : private Node {
    Node *head;
    Node *tail;
    Node *revList(Node *head) {
    if(head == nullptr || head->next == nullptr)
    return head;
    Node *ptr = revList(head->next);
    Node *temp = head->next;
    temp->next = head;
    head->next = nullptr;
    return ptr;
    }
    public:
    ~LinkedList() {deleteEntireList();}
    LinkedList() : head(nullptr), tail(nullptr) {}
    Node *getHead() {
    return head;
    }
    Node *getTail() {
    return tail;
    }
    void addBeg(int data) {
    Node *temp;
    if(head == nullptr && tail == nullptr) {
    temp = new Node(data);
    head = temp;
    tail = temp;
    return;
    }
    temp = new Node(data);
    temp->next = head;
    head = temp;
    temp = nullptr;
    }
    void addEnd(int data) {
    Node *temp;
    if(head == nullptr && tail == nullptr) {
    temp = new Node(data);
    head = temp;
    tail = temp;
    return;
    }
    temp = new Node(data);
    tail->next = temp;
    tail = temp;
    temp = nullptr;
    }
    void addAtPos(int pos, int data) {
    if(pos next;
    if(temp == nullptr) return;
    i++;
    }
    if(temp->next == nullptr) {
    addEnd(data);
    return;
    }
    Node *newNode = new Node(data);
    newNode->next = temp->next;
    temp->next = newNode;
    }
    void deleteBeg() {
    if(head == nullptr && tail == nullptr) return;
    Node *temp = head;
    if(head == tail) {
    head = nullptr;
    tail = nullptr;
    delete temp;
    temp = nullptr;
    return;
    }
    head = head->next;
    delete temp;
    temp = NULL;
    }
    void deleteEnd() {
    if(head == nullptr && tail == nullptr) return;
    Node *temp = head;
    if(temp->next == nullptr) {
    deleteBeg();
    return;
    }
    while(temp->next->next) {
    temp = temp->next;
    }
    Node *ptr = temp->next;
    temp->next = nullptr;
    tail = temp;
    delete ptr;
    ptr = nullptr;
    }
    void deleteFromPos(int pos) {
    if(head == nullptr && tail == nullptr) return;
    if(pos next == nullptr) return;
    while(i < pos - 2) {
    temp = temp->next;
    if(temp->next == nullptr) return;
    i++;
    }
    if(temp->next->next == nullptr) {
    deleteEnd();
    return;
    }
    Node *ptr = temp->next;
    temp->next = ptr->next;
    delete ptr;
    ptr = nullptr;
    }
    void deleteEntireList() {
    Node *temp = head;
    head = head->next;
    while(head) {
    delete temp;
    temp = head;
    head = head->next;
    }
    delete temp;
    temp = head;
    head = nullptr;
    tail = nullptr;
    }
    void reverseList() {
    Node *temp1 = head;
    Node *temp2 = head;
    head = tail;
    tail = revList(temp1);
    tail = temp2;
    }
    void printList() {
    if(head == nullptr && tail == nullptr) {
    cout

  • @Shivanai_h
    @Shivanai_h 2 ปีที่แล้ว

    If anybody get that tail thing please let me know also😢 how leftsortedlist![1] index can be tail.. there could be more than 2 elements in left sorted list then index 1 cant be tail...please correct me if I'm wrong...i didn't get this thing

    • @Pepcoding
      @Pepcoding  2 ปีที่แล้ว

      For better insights, visit nados.pepcoding.com, post your doubts, community will help you out there.

    • @rishitripathi5617
      @rishitripathi5617 2 ปีที่แล้ว +1

      seeee 29:00

    • @rishabhjain5199
      @rishabhjain5199 2 ปีที่แล้ว

      @@rishitripathi5617 bhai btaio kaise hua left[1] tail?

    • @crazyduniya128
      @crazyduniya128 2 ปีที่แล้ว +1

      leftSortedlist[1] is tail because quicksort_ function return 2 size array {head, tail}. Don't confuse between segregation returned array. the array return by segregation function returns that head of left and right partition and pivot node -> {leftHead, pivot, rightHead}, and after the recursive call when base case reached means we have null or single node the we are return arra with just head and tail after both left and right call we are merging. Dry run to get better understanding.

    • @crazyduniya128
      @crazyduniya128 2 ปีที่แล้ว

      @@rishabhjain5199 leftSortedlist[1] is tail because quicksort_ function return 2 size array {head, tail}. Don't confuse between segregation returned array. the array return by segregation function returns that head of left and right partition and pivot node -> {leftHead, pivot, rightHead}, and after the recursive call when base case reached means we have null or single node the we are return arra with just head and tail after both left and right call we are merging. Dry run to get better understanding.

  • @abhishekkamboj7150
    @abhishekkamboj7150 2 ปีที่แล้ว

    Tail vala concept bilkul ni samaj aya 1 index p tail kha rakhi hu bhai iska jikar kha hh isme

    • @Pepcoding
      @Pepcoding  2 ปีที่แล้ว +1

      Post your doubts on nados.pepcoding.com our community will help you out.

    • @Shivanai_h
      @Shivanai_h 2 ปีที่แล้ว

      Same i also didn't get..

    • @rishabhjain5199
      @rishabhjain5199 2 ปีที่แล้ว

      answer mila?

  • @iamrishabhpanchal
    @iamrishabhpanchal 3 ปีที่แล้ว +3

    Hello sir, please tell Bhavesh sir to complete excel clone we are waiting for a long time sir please🙏🙏

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว +6

      Bhavesh sir ki shaadi hai kal

    • @iamrishabhpanchal
      @iamrishabhpanchal 3 ปีที่แล้ว +4

      Wow🤩 Congratulations🥳 Bhavesh sir!
      Shadi me nahi bulaya aapne hame🥺

  • @anandchowdary6832
    @anandchowdary6832 3 ปีที่แล้ว +1

    English please