• 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 3-dimensional array.

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was asked in some of the interview, it sounds fairly simple but I couldnot crack it.
Q] An array say x[][][] is to be sorted in decending order of y[].
Assume int x[][][]=new int[100][7][2];
Assume int y[]=new int[100];

The numbers in last dimension contains pair and should not be separated from each other.
Use any sort algorithm.

What I tried was:

However I am not getting the answer. I am finding it very hard to visualize this.
please help me if you can
 
Marshal
Posts: 76450
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish Schottky wrote:. . . I am finding it very hard to visualize this. . . .

I am not surprised. You have posted a mass of code which won't compile, with number literals like 7, and c and ply appearing mysteriously. What is y, which doesn't appear to be part of the array?

You will have to sit down with a pencil and paper and write down what algorithm you would use. Write down what you think "sorting" an array means.

The idea behind such interview tests is to see how you approach a problem. If you simply write impenetrable code they won't offer you the job.
 
Campbell Ritchie
Marshal
Posts: 76450
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too difficult for "beginning". Moving thread.
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic