4 Replies - 2447 Views - Last Post: 10 September 2012 - 01:56 AM Rate Topic: -----

#1 dreadlord  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 10-September 12

Data structures. Basic stack, queue and linkedlist questions.

Posted 10 September 2012 - 01:08 AM

Hello,

This is a very simple and basic doubt. I am learning data structure for C.

I learnt what are stack and queue and their implementation.
Stack - It is basically like a pile of book on top and explained with push and pop operators.LIFO. (right?)

Queue - This is also just like the basic queue every where we find. The first that enters goes out.We use two operators, ADD and DEL. (right?)

Ok, what are linked list exactly? I sort off know what that is? could some one be more specific.
And what are pointers? (i know pointers hold the address of an address which holds the value)
but I don't understand over all, where do we use them?

Please answer my question one by one. It would be a great help. I am naive. Please do bare.
Thanks a ton.

Is This A Good Question/Topic? 0
  • +

Replies To: Data structures. Basic stack, queue and linkedlist questions.

#2 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1635
  • View blog
  • Posts: 3,111
  • Joined: 30-May 10

Re: Data structures. Basic stack, queue and linkedlist questions.

Posted 10 September 2012 - 01:25 AM

http://en.wikipedia....iki/Linked_list
The second paragraph pretty much nails it, regarding stacks and queues.
Was This Post Helpful? 1
  • +
  • -

#3 dreadlord  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 10-September 12

Re: Data structures. Basic stack, queue and linkedlist questions.

Posted 10 September 2012 - 01:40 AM

Ok now I am sortoff clear with linkedlist.

Linked list are basically data types used by abstract data types. right? Like stack and queues.
Linked list mainly rely on pointers.

So, can you name some more abstract data types and some more data structure like linked list.

I will give me a rough idea and also a lead to learn more other than these.

One more thing,
Pretty basic,
1)what is that return 0 and return 1 in c?
return 0 means the programs has ended properly? and return 1 means there is still something?

2) what is unsigned namespace std;
I googled, and noticed that people put them up because incase you use cin and cout, you need them in the beginning of the program. Is that so?
I did a lot of programs in borland c++ and i never put any such things? I normally replaced printf to cout and scanf to cin , thats all I did.

Thanks a ton
Was This Post Helpful? 0
  • +
  • -

#4 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1072
  • View blog
  • Posts: 4,532
  • Joined: 09-June 09

Re: Data structures. Basic stack, queue and linkedlist questions.

Posted 10 September 2012 - 01:49 AM

Pointers are used in many different contexts, but one of the biggies is to avoid copying data when you don't need to

I.e.
#include <stdio.h>
typedef struct { char data[1024 * 1024; } BigData; // 1 MB

// pass by value, copies 1 MB of data to make a new BigData structure
void passByValue(BigData bd) {}

//pass by pointer, copies no data. Only allocates a new pointer to point to the memory
//of where the parameter was passed. Note that any changes to the data of this parameter
//will reflect on the callers argument
Void passByPointer(BigData *bd) {}


Was This Post Helpful? 0
  • +
  • -

#5 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1635
  • View blog
  • Posts: 3,111
  • Joined: 30-May 10

Re: Data structures. Basic stack, queue and linkedlist questions.

Posted 10 September 2012 - 01:56 AM

> 1)what is that return 0 and return 1 in c?
Actually, there is only 0, EXIT_SUCCESS and EXIT_FAILURE.
Any other values are going to be specific to an implementation. VMS for example would treat 1 as success, whereas Unix based systems treat it as failure.

> 2) what is unsigned namespace std;
Well apart from it being "using" and not "unsigned", you can read about namespaces here -> http://www.cplusplus...ial/namespaces/
If your compiler doesn't understand namespaces, then it is obsolete and you should upgrade.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1