• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Sorting Lists from Arrays

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,

quick edit as my previous questions was quite vague.

I am working on this "Facebook/ Google Interview Question" and found some solutions online I am trying to understand.

This is my current approach to Order K Ordered lists into on single list:



My problem now is, that l2.next and the x.val lines are not working.
It shows me that this is not a field and I don't not understand why?

Can somebody help me out because it was working for another project in another class...
 
Bartender
Posts: 3673
151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could it be that val and next are methods of the IntDoubleList class? So that you need list.val() and list.next()?

And can you explain why the sort method is necessary?

If you have an array of sorted IntDoubleLists, then all you have to do is:
 
Sheriff
Posts: 6456
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It shows me that this is not a field and I don't not understand why?


Are you getting an error message?  Can you post the entire message?
 
Piet Souris
Bartender
Posts: 3673
151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just realized where the sort method is good for. Clever!
 
Michael Grünau
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the late reply.

The Error message is the following:
val cannot be resolved or is not a field
next cannot be resolved or is not a field
 
Marshal
Posts: 66635
251
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We need a lot more details to be able to help you with that error message.
  • Where are val and next declared?
  • Do they have private access?
  • How many different classes are you using?
  •  
    Michael Grünau
    Ranch Hand
    Posts: 53
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sorry for the lack of information.

    As the Code from above was from another source I decided to write my own for better understanding and it worked just fine.
    Still, thanks for the help!
     
    Campbell Ritchie
    Marshal
    Posts: 66635
    251
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well done Please explain how you improved on the old code.
     
    Pay attention! Tiny ad!
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!