Define the self-referential structures, C/C++ Programming

Assignment Help:

Define the Self-Referential Structures?

It is occasionally desirable to include within a structure one member that is a pointer to the parent structure type. Generally in terms this can be expressed as

struct tag
{
member 1;
member 2;
. . . . .
struct tag *name;
} ;

Where name refers to the name of a pointer variable therefore the structure of type tag will contain a member that points to another structure of type tag. Such structures are called as self-referential structures.

A C program contains the following structure declaration.

struct list_element
{
char item[40];
struct list_element *nextj
} ;

This is a structure of type list_element and the structure encloses two members a 40-element character array, called item, and a pointer to a structure of the same type (that is a pointer to a structure of type list_element), called next. Thus this is a self-referential structure. .

The Self-referential structures are extremely useful in applications that involve linked data structures, such as trees and lists. The fundamental idea of a linked data structure is that each component within the structure includes a pointer indicating where the next component is able to be found. Consequently the relative order of the components can simply be changed simply by altering the pointers. As well individual components can easily be deleted or added again by altering the pointers. As a result, a linked data structure isn't confined to some maximum number of components. Somewhat the data structure can expand or contract in size as required.

Figure shown below exemplify a linked list containing three components. Every component consists of two data items a string, and a pointer that references the next component within the list. Therefore the first component contains the string "red" the second contains "green" and the third contains "blue". The start of the list is indicated by a separate pointer, which is labeled "start". As well, the end of the list is indicated by a special pointer called as "NULL".

1623_Self-Referential Structures.png


Related Discussions:- Define the self-referential structures

Algorithm, for different operation multiple stack

for different operation multiple stack

C program, program for lexicographically precedes the given input permutati...

program for lexicographically precedes the given input permutation

Summations, How do you write the code for summations

How do you write the code for summations

Draw pie chart in c++ program, Draw pie chart in c++ program: int main...

Draw pie chart in c++ program: int main() {                 char cmd;                   cout                 cout                 cmd = toupper(getch());

Working of ordered linked list, Working Ordered linked list: • Eachint...

Working Ordered linked list: • Eachinteger in the queue is stored inside of a QueueItem. The QueueItem contains the integer, and a pointer to the next item in the queue. Fo

Create three classes program in cpp, In this worksheet you are asked to wri...

In this worksheet you are asked to write three classes in C++: Lecture class, Course class and University class. The classes relate to each other in the way that a Course has many

Explain the loop statements in computer programming, Explain the Loop State...

Explain the Loop Statements in Computer Programming? 1. C gives you a choice of three kinds of loop, while, do while and for. 2. The while loop remain repeating an action until

Padovan string, padovan string program in java // aakash , suraj , p...

padovan string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class PadovanString {     publ

Program to compute distance travelled by ball, Produce a pseudo code to be ...

Produce a pseudo code to be used for development compute and display some data on the bounces a ball will make when dropped from a given height. To simplify the problem, you ass

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd