Posts

Family Tree using Generalized Linked List

Image
Hello and Welcome. In the previous blog post, we saw how we can store polynomials using a linked list. We also saw various types of Linked Lists and studied in detail about the Generalized Linked Lists(GLLs). This is the final blog of this blog series. In this blog, we will go a step further and learn how to use GLLs to implement a family tree. This will enable us to store hierarchical data. Let's start with the basics of a family tree. What is Family Tree? A  family tree , or pedigree chart, is a chart representing family relationships in a conventional tree structure . A simple family tree. The algorithm for implementing the family tree is as follows: -         Create a struct node with: - ·        name pointer ·        spouse pointer ·        pointer to sibling node, ·        pointer to the chi...

Representation of polynomials using Generalized Linked List

Image
Hello and welcome. In this week's blog, we will look at a specific application of linked lists. We have dealt with polynomials since high school and now we will write a program to add two polynomials. We will be using a linked list to store the polynomials. Let's start by understanding what is a linked list? What is a Linked List? A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the below image: Image Credits - GeeksforGeeks Linked List is a sequence of links that contains items.  Each link contains a connection to another link.  Linked list is the second most-used data structure after array. There are various types of Linked Lists. Most commonly used are singly linked lists, doubly linked lists, and circularly linked lists. Each type has its own applications. So, what is a Generalized Linked List? A Generalized Linke...

Dynamic Memory Allocation in C++

Image
Understanding of Dynamic memory allocation is very important for a programmer. It enables the programmer to make optimal use of the memory available. Let’s understand memory allocation from scratch.   A typical memory representation of a C program consists of following sections: text segment, initialized data segment, uninitialized data segment, stack and heap. We will not go into the details of the first three sections. However, we will have a look at stack and heap in detail. In C/C++ memory can be allocated based on either stack or heap. Memory from the stack is occupied by variables declared inside the function. The heap is the unused part of the memory of a program which can be used to allocate memory dynamically during runtime. The differences between them have been enlisted below. Stack Heap Memory is allocated in contiguous block. Memory is allocated in a random order Allocation and De-allocation is done automatically by ...
Programming Paradigms: An Overview Hello and Welcome to our Blog Series. All blogs will be related to Programming with a focus on Object Oriented Programming. This blog is the first one out of the many blogs which will be coming up over the course of next few months. A new blog will be uploaded every Monday starting from today (27 th January, 2020). This will be a series of 16 blogs and throughout the series and we wish to provide interesting content to our audience. This initiative is a part of the Home Assignments for the course Object Oriented Programming which I have taken up in this semester. What is Programming? Programming is the process of instructing a computer perform a desired task. Like humans speak various languages, the computers can also be instructed using different languages. Among them the most popular ones are C, C++, Java, Python, JavaScript, C# to name a few. Each language has its pros and cons. A language is selected based on the application, specific...