RunRyder RC
 4  Topic Subscribe
WATCH
 3 pages [ <<    <    ( 1 )     2      3     NEXT    >> ] 1851 views POST REPLY
HelicopterOff Topics › Any C++ programmers here?
12-09-2004 02:42 AM  13 years agoPost 1
penggoy

rrNovice

NY

My Posts: All  Forum  Topic

Hello can anyone here please help me make a program for this problem

Write a void function that takes a linked list of integers and reverse the order of its nodes. The function will have one call-by-reference parameter that is a pointer to the head of the list. After the function is called, this pointer will point to the head of a linked list that has the same nodes as the original list, but in the reverse of the order they had in the original list. Note that your function will neither create nor destroty any nodes. It will simply rearrange nodes. Place your function in a suitable test program.

many thnx

PM  EMAIL  Attn:RR  Quote
12-09-2004 03:28 AM  13 years agoPost 2
pilotError

rrKey Veteran

Long Island, NY

My Posts: All  Forum  Topic

Do the work...

It's a good little exercise...
Since I'm watching TV, I'll let you deal with any syntax / compile issues.

void reverseList(Node * head)
{
Node *newHead, *temp;

newHead = temp = head;

while (temp->next)
{
temp = temp->next;
temp->next = newHead;
newHead = temp;
}

head = newHead;
}

Good Judgement comes from Experience. Great Judgement comes from Bad Experience.

PM  EMAIL  GALLERY  Attn:RR  Quote
12-09-2004 04:24 AM  13 years agoPost 3
Spitfire_mk5

rrKey Veteran

Canada

My Posts: All  Forum  Topic

another C++ hack here,

but do your own homework...

PM  EMAIL  GALLERY  Attn:RR  Quote
12-09-2004 06:49 AM  13 years agoPost 4
Colibri

rrKey Veteran

The Netherlands

My Posts: All  Forum  Topic

linked list of integers
A single linked list or a double linked list?
Note that your function will neither create nor destroty any nodes. It will simply rearrange nodes. Place your function in a suitable test program.
Yes master, your wish is my command!

@pilotError:
oid reverseList(Node * head)
{
Node *newHead, *temp;

newHead = temp = head;

while (temp->next)
{
temp = temp->next;
temp->next = newHead;
newHead = temp;
}

head = newHead;
}
That must have been a long TV program because you've created an endless loop.

Tim

PM  EMAIL  GALLERY  Attn:RR  Quote
12-09-2004 08:41 AM  13 years agoPost 5
Colibri

rrKey Veteran

The Netherlands

My Posts: All  Forum  Topic

Try this. (formatting is a little off because RR doesn't seem to accept leading whitespace).

void ReverseList(Node **head)
{
if (!head) { return; }

Node *newHead = *head;
Node *temp = newHead->next;

newHead->next = NULL;
while(temp)
{
Node *tempNext = temp->next;

temp->next = newHead;
newHead = temp;
temp = tempNext;
}

*head = newHead;
}

Tim

PM  EMAIL  GALLERY  Attn:RR  Quote
12-09-2004 11:41 AM  13 years agoPost 6
PaulH-MA

rrVeteran

Boston, MA

My Posts: All  Forum  Topic

You never mentioned if you were using the "list" class from the Standard Template Library (STL) or not. If you are, you can simply call the "reverse" member function on your list.
using std::list;

void reverseList( list< int >& theList )
{
theList.reverse( );
}

--Paul

TREX 450
Bergen Intrepid Gasser x2

PM  EMAIL  Attn:RR  Quote
12-09-2004 03:29 PM  13 years agoPost 7
Spitfire_mk5

rrKey Veteran

Canada

My Posts: All  Forum  Topic

This is too much like a homework question to get away with 1 call to STL.
This should all be in any good first year CS textbook

PM  EMAIL  GALLERY  Attn:RR  Quote
12-09-2004 04:33 PM  13 years agoPost 8
pilotError

rrKey Veteran

Long Island, NY

My Posts: All  Forum  Topic

That must have been a long TV program because you've created an endless loop.
Hahaha, oh well, see what happens when you don't pay attention!

He probably pulled an all nighter trying to get it to work!

Sorry about that.

Mike...

Good Judgement comes from Experience. Great Judgement comes from Bad Experience.

PM  EMAIL  GALLERY  Attn:RR  Quote
12-09-2004 11:52 PM  13 years agoPost 9
PaulH-MA

rrVeteran

Boston, MA

My Posts: All  Forum  Topic

I'm a Software Engineer, so I have been through this myself. I know this sounds like a homework question, which is why I gave the easy answer.
This is too much like a homework question to get away with 1 call to STL. This should all be in any good first year CS textbook

--Paul

TREX 450
Bergen Intrepid Gasser x2

PM  EMAIL  Attn:RR  Quote
12-10-2004 03:59 AM  13 years agoPost 10
penggoy

rrNovice

NY

My Posts: All  Forum  Topic

hello,
sorry for the late reply. Yes it is our homework. I posted it here because I have no idea on how to start this. Thanks to all who replied.

PaulH-MA - im not yet allowed to use the STL.

pilotError and tvhalter - thanks for the pseudocode.

Last questions how long have u guys been into programming? The reason I asked is because Im going to graduate this semester (Computer Science) and I dont have any work experience related to my course. What do I have to do to be competitive out there especially now that most companies are hiring programmers from other countries, few companies are hiring and plus there are a lot of applicants (newly grads and experienced programmers) who wants that single job position.

Many thanks in advance

PM  EMAIL  Attn:RR  Quote
12-10-2004 04:09 AM  13 years agoPost 11
Spitfire_mk5

rrKey Veteran

Canada

My Posts: All  Forum  Topic

This is grad level ?!!?!?

This is the kind of thing we did in first year courses.

Best bet for work experiance is to go check if your school offers an internship program.

PM  EMAIL  GALLERY  Attn:RR  Quote
12-10-2004 04:13 AM  13 years agoPost 12
penggoy

rrNovice

NY

My Posts: All  Forum  Topic

Yes its suppose to be for fourth year fall semester students. We have to take Java 1 and 2 first then C++ 1 and then this course (C++ 2).

PM  EMAIL  Attn:RR  Quote
12-10-2004 05:02 AM  13 years agoPost 13
Secret Squirrel

rrKey Veteran

New Zealander living in Melbourne, Australia

My Posts: All  Forum  Topic

What do I have to do to be competitive out there
Learn .Net

*Flame suit on*

-------------
Simon Lockington

PM  EMAIL  HOMEPAGE  Attn:RR  Quote
12-10-2004 11:21 AM  13 years agoPost 14
PaulH-MA

rrVeteran

Boston, MA

My Posts: All  Forum  Topic

That is actually very true! The latest independent studies show that Software Engineers are leaving Java in droves to use C# and the .Net framework.

I myself am writing a large application that extends SQL Server. The DLL that contains the extended procedures is written in managed C++, but the code that does the heavy lifting is in another DLL that is completely written in C#. Being able to flip back and forth between them that easily is a HUGE deal!
Learn .Net

*Flame suit on*

--Paul

TREX 450
Bergen Intrepid Gasser x2

PM  EMAIL  Attn:RR  Quote
12-10-2004 03:21 PM  13 years agoPost 15
pilotError

rrKey Veteran

Long Island, NY

My Posts: All  Forum  Topic

Pengoy

Where in NY are you?

The job market in NYC is pretty bad. I know alot of people had to pretty much take a huge paycut to get a job. Everything gets outsourced to India / China these days.

The DBA market still seems pretty strong though, there still some good salary there.

I've been in the game for 15 years, but I do mostly Unix / VMS back end type stuff. Java, C, C++, Sybase, Oracle. It's very difficult to compete as a C++ programmer or Java Programmer (everyone that graduates learns it). You need to learn SQL, or any middleware is a big plus.

What do you like to do? Do you like front end development, database, communications?

Good Luck,

Mike...

Good Judgement comes from Experience. Great Judgement comes from Bad Experience.

PM  EMAIL  GALLERY  Attn:RR  Quote
12-10-2004 03:37 PM  13 years agoPost 16
Dan C

rrApprentice

Barnsley, Yorkshire

My Posts: All  Forum  Topic

Try a different tack rather than become a PC code monkey have a look at embedded systems etc and see what the have to offer.

embedded systems are things like

Tv controls and the Tv
set top boxes ( echosar dp921 is a linux based horror)
engine management
mobile phones etc
life critical systems
cars based electronics
avionics or aerospace electronics
weapons
life critical equipement eg medical equipement.

All of these can be programmed in assembler, C or C++ but C++ is not a safe langauge so more than likely it will be assembler or a sub set of C (eg for europe it could be following the MISRA rule set)

The range of hardware is huge I use 8 pin micros in assembler to 700mHz ARM based devices with C++.

I work for Honeywell and we have heard recently of all new PC work is to specced so that the engineers in India can have a go and it sadly looks like all PC tools will be given to the low cost centers.

On the embedded side there is not a huge skill base in India yet but I belive it will be the next thing to go out once all the easy PC stuff has gone.

Skills that would set a person apart from the herd is the ability to be able to set up hardware from scratch, be able to set up compilers and tools to work on different platforms, the use of clever tools such as UML based code generating tools and the verfication modules to make sure the system does as required.

Learn to code in a efficient consistant safe manner with plenty of meaningfull comments ( forget being clever as there is nothing worse than picking up a section of code some "hotshot" has crafted
that is unreadable.

Concentrate on the design of the application and getting that right as once you have the design sorted you can get a code monkey to follow it

PM  EMAIL  GALLERY  Attn:RR  Quote
12-10-2004 05:40 PM  13 years agoPost 17
PaulH-MA

rrVeteran

Boston, MA

My Posts: All  Forum  Topic

8-pin micro? I love the PIC processors. They're great for moving around stepper motors and the like.
The range of hardware is huge I use 8 pin micros in assembler to 700mHz ARM based devices with C++.

--Paul

TREX 450
Bergen Intrepid Gasser x2

PM  EMAIL  Attn:RR  Quote
12-10-2004 06:11 PM  13 years agoPost 18
Dan C

rrApprentice

Barnsley, Yorkshire

My Posts: All  Forum  Topic

yep its amazing what you can do with only 512 odd instructions and a tiny bit of Ram

PM  EMAIL  GALLERY  Attn:RR  Quote
12-10-2004 06:18 PM  13 years agoPost 19
Colibri

rrKey Veteran

The Netherlands

My Posts: All  Forum  Topic

thanks for the pseudocode.
It's not pseudocode. It actually compiles with a C++ compiler.

Tim

PM  EMAIL  GALLERY  Attn:RR  Quote
12-10-2004 06:21 PM  13 years agoPost 20
eSmith

rrVeteran

Edmonton, Alberta, Canada

My Posts: All  Forum  Topic

Paul, you stated: "The latest independent studies"

Do you really think if you peel back the onion layers you won't find M$ funding this "independent" study?

They are infamous for doing this, they create, opps, sorry, Commission, "Independant" study projects all the time with an amazing frequence showing big boosts in M$ products.

I wouldn't believe a word of it, I'm not seeing it among the developer forums of the user groups I frequent or hearing it from the developers I work with directly.

Delphi is more popular than C#. C# was meant more to slice up the developer market so MS could get a foothold back after everyone understood VB is kindergarden programing for newbies and switched to a RAD product with some real power.

I agree that you want to develope SQL skills, they are very valuable right now and really, SQL is just about a no brainer. I've been working at a manufacturing plant coding a custom ERP. Lots of UI development, Backend work and the like. It's an interesting market in that there are not a lot of developers familliar with the software requirments for our business. That makes it hard to shop out to India. The software gets so complex they would have to work here a year or two just to figure out what we do.

Not to say the coding is difficult but the business rules we use get kinda convoluted so it takes some inside knowledge to understand all the hoops the data needs to jump through.

-eSmith.

http://www.edmheli.ca

PM  EMAIL  HOMEPAGE  GALLERY  Attn:RR  Quote
WATCH
 3 pages [ <<    <    ( 1 )     2      3     NEXT    >> ] 1851 views POST REPLY
HelicopterOff Topics › Any C++ programmers here?
 Print TOPIC  Make Suggestion 

 4  Topic Subscribe

Monday, January 22 - 6:31 pm - Copyright © 2000-2017 RunRyder   EMAILEnable Cookies

Login Here
 New Subscriptions 
 Buddies Online