473,403 Members | 2,366 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,403 software developers and data experts.

linked lists problems

2
hi,

i need to find the highest int value in a linked list of integer objects. i've extracted primitive int values using an iterator and .intValue but im unsure on how to find the max int value in the list. do i need to use Integer.MAX_VALUE?

any help is appreciated.
thanks
Feb 6 '07 #1
3 2718
r035198x
13,262 8TB
hi,

i need to find the highest int value in a linked list of integer objects. i've extracted primitive int values using an iterator and .intValue but im unsure on how to find the max int value in the list. do i need to use Integer.MAX_VALUE?

any help is appreciated.
thanks
Let's see the code that you've done
Feb 6 '07 #2
b8asj9
2
Expand|Select|Wrap|Line Numbers
  1.     int i = Integer.MAX_VALUE;
  2.  
  3.     ListIterator iter= l.listIterator();
  4.     while (iter.hasNext()) {
  5.         int i = ((Integer)iter.next()).intValue();
  6.         if (i < 0) {
  7.         lrgIdx = i;
  8.     }
  9.     return lrgIdx;
  10.     }
  11.  
sorry if the logic is not correct, but this is my first attempt.
Feb 6 '07 #3
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1.     int i = Integer.MAX_VALUE;
  2.  
  3.     ListIterator iter= l.listIterator();
  4.     while (iter.hasNext()) {
  5.      int i = ((Integer)iter.next()).intValue();
  6.      if (i < 0) {
  7.         lrgIdx = i;
  8.     }
  9.     return lrgIdx;
  10. }
  11.  
sorry if the logic is not correct, but this is my first attempt.
To find the largest element in a list, You must first assign the first element to be the largest. Then move through each of the elements comparing with the currently largest element. If current element is bigger than the currently largest element, then you make current element the largest element and move on to the next element until you've gone through all the elements.
Feb 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chris Ritchey | last post by:
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am...
2
by: Skywise | last post by:
I am fairly new to linked lists. I am trying to write a class using linked lists. It seems to work fine, but I need to know if I have any resource leaks in it because I plan on using this class...
12
by: Jonathan Bartlett | last post by:
Just finished a new IBM DeveloperWorks article on linked lists, and thought you all might be interested. It's not an introduction -- it instead covers some of the more interesting aspects of...
3
by: s_subbarayan | last post by:
Dear all, 1)In one of our implementation for an application we are supposed to collate two linked lists.The actual problem is like this: There are two singularly linked lists, the final output...
17
by: Foodbank | last post by:
Hi, I have to write a program that will use linked lists to print the number of unique words, total words, and the most frequent word from a text file. I've gotten a decent amount of it done...
11
by: bofh1234 | last post by:
Hello, I am having a problem with linked lists. My program is based on a client server model. The client sends some packets of data to the server. The server reads those packets and is...
19
by: Dongsheng Ruan | last post by:
with a cell class like this: #!/usr/bin/python import sys class Cell: def __init__( self, data, next=None ): self.data = data
51
by: Joerg Schoen | last post by:
Hi folks! Everyone knows how to sort arrays (e. g. quicksort, heapsort etc.) For linked lists, mergesort is the typical choice. While I was looking for a optimized implementation of mergesort...
6
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
8
by: dmp | last post by:
What are Linked list? Please somebody show some ready made programs of linked list
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.