473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Printing a strings linked list lexicographically, time O(n^2), space O(1), no swap

Hi,

It has to be some stupid high school home task , that can be solved in
rather straightforward manner.
The pain in the @ss is the requirement not to touch the original list,
that is: no swap between the elements is permitted.
O(n^2) is a bunch of time: the list can be even bubble sorted, but I
really fail to figure out how the hell I'm supposed to handle the
sorting without building any additional structures and the requirement
not to modify the original list in any way.

Any help/tip/advice will be appreciated,

Thanks.

Jan 9 '07 #1
2 1563
On 8 Jan 2007 22:33:41 -0800, "Billy" <st******@gmail.comwrote:
>Hi,

It has to be some stupid high school home task , that can be solved in
rather straightforward manner.
The pain in the @ss is the requirement not to touch the original list,
that is: no swap between the elements is permitted.
O(n^2) is a bunch of time: the list can be even bubble sorted, but I
really fail to figure out how the hell I'm supposed to handle the
sorting without building any additional structures and the requirement
not to modify the original list in any way.

Any help/tip/advice will be appreciated,
Wrong news group. That said, make n passes through the list. In each
pass find the smallest one that is larger than the last one printed.
Try comp.programming next time.

Jan 9 '07 #2
"Richard Harter" <cr*@tiac.netwrote in message
news:45***************@news.sbtc.net...
On 8 Jan 2007 22:33:41 -0800, "Billy" <st******@gmail.comwrote:
>>Hi,

It has to be some stupid high school home task , that can be solved in
rather straightforward manner.
The pain in the @ss is the requirement not to touch the original list,
that is: no swap between the elements is permitted.
O(n^2) is a bunch of time: the list can be even bubble sorted, but I
really fail to figure out how the hell I'm supposed to handle the
sorting without building any additional structures and the requirement
not to modify the original list in any way.

Any help/tip/advice will be appreciated,

Wrong news group. That said, make n passes through the list. In each
pass find the smallest one that is larger than the last one printed.
Try comp.programming next time.
Also, Billy, although I'm sure you noticed ... making N complete passes
through a list with N elements might be O(N**2).
Jan 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Brent W. Hughes | last post by:
I kind of hate to have to convert a string into a list, manipulate it, and then convert it back into a string. Why not make strings mutable?
6
by: Steve Lambert | last post by:
Hi, I've knocked up a number of small routines to create and manipulate a linked list of any structure. If anyone could take a look at this code and give me their opinion and details of any...
12
by: Eugen J. Sobchenko | last post by:
Hi! I'm writing function which swaps two arbitrary elements of double-linked list. References to the next element of list must be unique or NULL (even during swap procedure), the same condition...
32
by: Clunixchit | last post by:
How can i read lines of a file and place each line read in an array? for exemple; array=line1 array=line2 ...
6
by: Julia | last post by:
I am trying to sort a linked list using insertion sort. I have seen a lot of ways to get around this problem but no time-efficient and space-efficient solution. This is what I have so far: ...
7
by: temp34k45k | last post by:
I need to evaluate two strings for their order. The strings contain Letters (A thru Z upper case only) and Numbers (0-9) and the decimal point (.). I need an order like the list that follows: ...
8
by: Jeff Bown | last post by:
Consider implementing a (doubly) linked list. The simplest strategy is to provide functions item_t add_item(item_t predecessor); void delete_item(item_t item); where add_item allocates memory...
10
by: Aditya | last post by:
Hi All, I would like to know how it is possible to insert a node in a linked list without using a temp_pointer. If the element is the first element then there is no problem but if it is in...
20
by: sirsnorklingtayo | last post by:
hi guys please help about Linked List, I'm having trouble freeing the allocated memory of a single linked list node with a dynamic char* fields, it doesn't freed up if I use the FREE()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.