answersLogoWhite

0

What is static and dynamic data structure?

Updated: 8/10/2023
User Avatar

Kushalkamra

Lvl 1
13y ago

Best Answer

In dyanamic data structure emory allocation for the data structure takes place at run time,only requered amount of memory is allocated(eg.linked lists).In static data structure memory is reseved at the time of compilation(eg.arrays).

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

A static data structure is any structure where the size of the structure is known at compile time and can therefore be statically allocated within the program's own data segment (the stack). A dynamic data structure is one where the initial size is unknown at compile time, or where the size of the structure may vary at runtime, and must be dynamically allocated upon the heap (the free store).

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Static Data Structures

  • Fast access to elements
  • Expensive to insert/remove element
  • Have fixed maximum size
  • Memory is reserved at the time of compilation.

Eg: Arrays, Records

Dynamic Data Structures

  • Fast insertion/deletion of element
  • Slower access to the element
  • Have flexible size
  • Memory allocation for the data structure takes place at the run time, only required amount of memory is allocated.

Eg: Link lists, Stacks, Ques, Trees

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Static data is allocated in the program's data segment at compile time. Static data must be fixed-length (where the size is known at compile time). The data segment is also fixed-length; it cannot be increased or decreased at runtime. The data segment is used specifically to store a program's constants, static variables and global data.

Dynamic data is allocated in the free store (also known as the heap or dynamic memory) at runtime and the data can either be fixed length or variable length. However, there is a finite amount of dynamic memory available although virtual memory can make more memory available than physically exists. Even so, there can never be more memory than can be physically addressed by the architecture. In order to keep track of dynamic allocations, you also need a resource handle which may be allocated statically.

There is also a third area of memory known as the stack. This is specifically used for local variables, function arguments, return addresses and exception handlers, all of which have fixed-length. Stack memory is allocated at runtime and is itself fixed length. A stack pointer is used to determine how much of the stack is currently in use. Since it is already allocated, it is much quicker than dynamic memory because only the stack pointer needs to move in order to make memory available. However, it is fixed size so is unsuitable for large data structures or structures that are variable length.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

First let's clarify what we mean by static in this context. A static data structure is any named object of any type that is allocated within the program's data segment. That's it! Although the term static is used in other contexts (static cast, static assertion, and so on) and is often incorrectly used as an antonym for dynamic (the antonym of static is nonstatic), this is the only definition that explicitly applies in this particular context. If an object is not allocated in the data segement then it is, by definition, a nonstatic object.

Static objects exist for the entire duration that a program is running. Static objects may be constant or variable. The only real difference is that static constants are allocated in a separate region of the data segment dedicated to read-only objects while static variables are allocated in the read/write region. The amount of storage allocated to the data segment is the sum of all static object sizes, including padding bytes for memory-alignment purposes. Therefore to be statically allocated, an object's size must be known at either compile time or link time, never at runtime.

To allocate an object in the data segment, an object must first be declared at file scope, function scope or class scope. Note that while function arguments (formal parameters) are local to the function in which they are declared, the function call mechanism is entirely reliant upon the stack to pass values to the function. Therefore function arguments are always nonstatic. Function scope therefore means variables or constants declared within the function body.

In most cases, an object must be declared with the static keyword in order to become static, however there are exceptions. For instance, a constant is implicitly static when declared at file scope or function scope but not when declared at class scope. In this case it must be explicitly declared a static member of the class otherwise it is a nonstatic member. And although the static keyword is optional for constants declared at file or function scope, you cannot explicitly declare a static constant at file scope if the constant also has explicit external linkage. This is often confusing because constants at file scope are implicitly static but also have external linkage by default. However, when you explicitly declare a static constant at file scope you are explicitly removing the implied external linkage so that it has internal linkage only. This is an unfortunate use of the static keyword that has nothing to do with the data segment, it simply prevents external files from declaring that same constant with external linkage (as they normally would).

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

what are static and dynamic implemention in data strucyure

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is static and dynamic data structure?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What does dynamic structure mean?

it is something to do with buildings and static


Are minorities scholarships still available after you have already started college?

Both static and dynamic structures are the sequence of statements. The only difference is that the sequence of statements in a static structure is fixed, whereas in a dynamic structure it is not fixed. That means


Differentiate between static ram and dynamic ram in tabular form any two differences?

· Static RAM: No refreshing, 6 to 8 MOS transistors · Dynamic RAM: Refreshed periodically, 3 to 4 transistors. · Static ram is more reliable · Dynamic ram is less reliable · Static ram is more expensive · Dynamic ram is less expensive · Static ram can store its data when computer is turned off · Dynamic ram looses data when computer is turned off. · A static memory cell takes a lot more space on a Chip than a dynamic memory cellby syed9230088668199


What is static anthropometric and dynamic anthropometric data?

Static anthropometric data refers to measurements taken when the body is at rest, such as height and sitting height. Dynamic anthropometric data, on the other hand, are measurements taken during movement or activity, such as stride length or reach distance. These data are used to design products, workspaces, and equipment that accommodate human variability in size and shape.


What is the difference between queues and circular queues?

A queue can use a dynamic array, or a linked list, but if using static memory, the queue becomes a circular queue because the underlaying data structure is a static circular array. This means the ends of the array are attached.


Definition of static HTML?

HTML by its very nature is static. If you desire to have a dynamic site, that requires a coding language like PHP, ASP, or other dynamic language. These dynamic languages typically also use HTML to create the structure for a web page.


Dynamic memory allocation in data structure?

This is where you allocate the data that you have. This gives you the opportunity to have everything in order.


Difference between static memory devices and dynamic memory devices?

static memory devices are those which stores data permanently as long as power is applied. and dynamic memory devices are those in which data is not permanently stored even with power applied,unless data is periodically rewritten into memory.


Compare and contrast dynamic memory allocation and the allocation of files in secondary storage?

Static Memory Allocation: Allocating the total memory requirements that a data structure might need all at once without regard for the actual amount needed at execution time. Dynamic Memory Allocation: The opposite strategy of static memory allocation - Dynamic Memory Allocation, involves allocating memory as-needed.


How does PHP differ from HTML in terms of application and structure?

In structure <?php ?> <html> </html> in application - one is static and another is dynamic. this much ......


Types of Internet static and dynamic - explain this?

Static: Not Moving Dynamic: Moving


Does comcast have static or dynamic ip's?

Dynamic unless you pay extra for a static.