• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Sorting Lists from Arrays

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5070
189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5070
189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just realized where the sort method is good for. Clever!
 
Michael Grünau
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 76462
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 66
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 76462
    366
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Well done Please explain how you improved on the old code.
     
    That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic