Tag: a
Create a Singly Linked List from an array
Suppose we have an int array and we want to create it into a singly linked list from it. Singly Linked List Our Node structure is, Advertisements struct node { int value; node * nextPtr; node(int val) { value = val; nextPtr = NULL; …
Remove Duplicate Elements from a Sorted Singly Linked List
Lets remove all duplicate elements from a sorted singly linked list. For example, Advertisements Suppose given linked list contains following elements in given order, 1, 2, 3, 4, 4, 5, 6, 7, 7, 7, 7, 9, 89 Frequently Asked: Reverse a Singly Linked List in a Single Iteration Create a Singly Linked List from an …
Remove Duplicate Elements from a Sorted Singly Linked ListRead More
Reverse a Singly Linked List in a Single Iteration
Suppose we have a linked list and we want to reverse it in Single iteration and O(n) complexity. Original Linked List, Linked List Reversed Linked List, Advertisements Reversed Linked List Our Node structure is, struct node { int value; node * nextPtr; node(int val) { value = val; …
Learn State Design Pattern by Designing a Simple Music System
Many times we need to develop systems / objects that provides services to outside world. But the response of each service is not always same, it depends upon its current internal state. When its internal state changes at run-time then its behaviour changes and same services acts differently. Advertisements For example, Suppose our system is …
Learn State Design Pattern by Designing a Simple Music SystemRead More
What’s good for a fresher : Development or Testing ?
If you are going to join a Software company as a fresher, then there might a question in your mind like, What’s good for my carrier – Testing Profile or Development Profile? Advertisements [showads ad=inside_post] The Answer is “It depends on what’s your interest and what you have planned for your future” like, Frequently Asked: …
What’s good for a fresher : Development or Testing ?Read More
C++ : How to split a string using String and character as Delimiter?
In this article we will see 2 techniques to split a std::string in C++ and return the result in std::vector<std::string> i.e. Splitting a std::string using a char as delimiter. Splitting a std::string using an another std::string as delimiter. How to Split a std::string using a char as delimiter: In this we will convert the passed …
C++ : How to split a string using String and character as Delimiter?Read More
Create a Binary Search Tree from an array
Lets discuss how to create a BST From an array. Advertisements Tree’s node structure is as follows, typedef struct node { int value; node * pLeft; node * pRight; node(int val = 0) { value = val; pRight = NULL; pLeft = NULL; } }node; Now create a getBST function that accepts an integer pointer …
Object Oriented Approach to Display a sequence of numbers without any For-Loop or Recursion
Suppose we have to display a sequence of numbers like from 10 to 20 i.e. 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 Advertisements without using any for-loop and recursion. Solution: Frequently Asked: Object Oriented Approach to Display a sequence of numbers without any For-Loop or Recursion We will use two concepts …
Object Oriented Approach to Display a sequence of numbers without any For-Loop or RecursionRead More
Designing Code to Convert the base of a Number to any other base in Number System
In this article we will discuss how to design a Class that represents the Number in a Number System and also provides the facility to convert the Base associated with that Number i.e. conversion from any Base to any other base like, octal to hexa or hexa to decimal etc. [showads ad=inside_post] Create a class Number that …
Designing Code to Convert the base of a Number to any other base in Number SystemRead More
Designing a Multiton: Singleton that returns 5 objects in cycle
Let’s Design a Multiton class i.e. a modified Singleton to return 5 objects in cycle. Logic to Create Multiton Advertisements Instead of keeping a static pointer as member variable keep a vector of pointers as member variable. Now also keep track of how many times getInstance() function is called. To do that use static member …
Designing a Multiton: Singleton that returns 5 objects in cycleRead More