Graphics Interview Questions
- 0of 0 votes
AnswerSuppose we have some input data describing a graph of relationships between parents and children over multiple generations. The data is formatted as a list of (parent, child) pairs, where each individual is assigned a unique positive integer identifier.
<p>
For example, in this diagram, 3 is a child of 1 and 2, and 5 is a child of 4:
<p>
1 2 4 15
\ / / | \ /
3 5 8 9
\ / \ \
6 7 11
<p>
<p>
Sample input/output (pseudodata):
<p>
parentChildPairs = [
(1, 3), (2, 3), (3, 6), (5, 6), (15, 9),
(5, 7), (4, 5), (4, 8), (4, 9), (9, 11)
]
<p>
<p>
Write a function that takes this data as input and returns two collections: one containing all individuals with zero known parents, and one containing all individuals with exactly one known parent.
<p>
<p>
Output may be in any order:
<p>
findNodesWithZeroAndOneParents(parentChildPairs) => [
[1, 2, 4, 15], // Individuals with zero parents
[5, 7, 8, 11] // Individuals with exactly one parent
]
<p>
n: number of pairs in the input
- Manoj May 04, 2021 in India for Senior Software Engineerpublic static void main(String[] argv) { int[][] parentChildPairs = new int[][]{ {1, 3}, {2, 3}, {3, 6}, {5, 6}, {15, 9}, {5, 7}, {4, 5}, {4, 8}, {4, 9}, {9, 11}}; findNodesWithZeroAndOneParents(parentChildPairs); } public static void findNodesWithZeroAndOneParents(int[][] parentChildPairs) { Map<Integer, List<Integer>> childAncestor = new HashMap<>(); for (int[] parentChildPair : parentChildPairs) { int parent = parentChildPair[0]; int child = parentChildPair[1]; if (!childAncestor.containsKey(child)) { childAncestor.put(child, new ArrayList<>()); } List<Integer> parentValue = childAncestor.get(child); parentValue.add(parent); childAncestor.put(child, parentValue); } System.out.println(childAncestor.toString()); dfs(childAncestor); } private static void dfs(Map<Integer, List<Integer>> childAncestor) { Set<Integer> childerOneParent = new HashSet<>(); Set<Integer> parentWithOutParent = new HashSet<>(); for (Map.Entry<Integer, List<Integer>> parent : childAncestor.entrySet()) { if (parent.getValue().size() == 1) { childerOneParent.add(parent.getKey()); } List<Integer> part = parent.getValue(); for (Integer p : part) { if (!childAncestor.containsKey(p)) { parentWithOutParent.add(p); } } } System.out.println(childerOneParent.toString() + " / " + parentWithOutParent.toString()); } }
| Report Duplicate | Flag | PURGE
Sap Labs Senior Software Development Engineer Graphics - 0of 0 votes
AnswersConsider the following 3D scene representing an old town's main square:
- bharsaklemukesh975 September 22, 2019 in India
• A single statue
o static geometry, high polygon count
o low complexity fragment shader
• A particle system simulating smoke
o animated, rendered as a large set of points
• A small set of characters
o animated geometry, medium polygon count
o medium complexity fragment shader
• A large set of buildings
o static geometry, low polygon count
o low complexity fragment shader
• A background image/skybox
• The camera/viewpoint is continuously moving within the scene.
How would you render the statue - by itself – using OpenGL to achieve maximum vertex performance (vertices/second)?
How would you render the particle system - by itself - using OpenGL to achieve maximum vertex performance (vertices/second)?
How would you render the scene - as a whole - most efficiently on a GPU using OpenGL?
Given that the 3D scene was being rendered correctly but that you wanted to improve the performance further, how would you determine if the main performance limitation/bottleneck was located in the application, in the vertex processing stage, or in the fragment processing stage?| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Graphics - 0of 0 votes
AnswersFriends have transitive property where if A is the friend of B, and B is the friend of C then A is also the friend to C. Like that we make friend circle.
- sonesh April 18, 2017 in United States
You have to find the number of such circles in a given list of friends
You are given a NxN matrix, where columns of each row will have either 'N' or 'Y', where 'N' represents not a friend and 'Y' represents Yes, they are friends.
Example :
YNY
NYN
YNY
The output is 2({0,2},{1}), as the 0 and 2 are friends of each other and 1 is another friend who is neither friend with 0 nor with 2.| Report Duplicate | Flag | PURGE
Two Sigma Software Engineer / Developer Graphics - 1of 1 vote
AnswersDefine a graph using Adjacency list where node and graphs are different entities, for example, Node is a struct/class and graph is set of nodes.
- sonesh April 07, 2017 in United States
The graph is an acyclic directed graph(may be a forest not necessarily connected).
Write an assignment copy constructor for this graph.
Please note that the copy constructor should create a new copy of the graph, including all its edges and vertices. Interviewer called this deep copy.| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Graphics - 0of 0 votes
AnswersAs you know, Computers were invented to solve practical business problems, we tend to ask practical applied questions. One of the key areas where we want to apply computers is simulation. As most of the people working in software are Engineers, here is the problem. It is called 3 body problem.
- NoOne October 15, 2016 in India
3 Bodies with masses [ m1, m2, m3 ] are initially positioned in the 3 points in the space, thus, having positions [ P1, P2, P3 ].
Observe that each Pi is nothing but [ xi, yi, zi ].
Once the initial condition is set, definitely gravity would work and they would start falling against each other. Write code to simulate this problem. Imagine G, the constant of gravity as 1.
How do you go about simulating it?
Hint : feynmanlectures.caltech.edu/I_09.html see 9.5
Face to face. Pen and Paper. Panel Interview, 2 person Panel. 60 Minutes. For Engineers only, was specifically told about it.| Report Duplicate | Flag | PURGE
Software Developer Algorithm Computer Science Graphics Math & Computation Programming Skills - -9of 11 votes
AnswersWhat are the screen dimensions of various iPhone models?
- thinkrightthru February 20, 2014 in India| Report Duplicate | Flag | PURGE
Facebook iOS Developer Graphics - -8of 8 votes
AnswersWhat is the screen dimensions of various iPhone models?
- thinkrightthru February 20, 2014 in India| Report Duplicate | Flag | PURGE
Facebook iOS Developer Graphics - -1of 5 votes
AnswersFind if 2 lists of rectangle are exactly equal. How would you sort the lists?
- chandeepsingh85 October 21, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Graphics - 0of 2 votes
AnswerWhat is high dynamic range rendering and why is it important for realistic rendering?
- vik October 04, 2013 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer Graphics - -5of 7 votes
Answersneed to implement a weather report functionality. user will provide the city name , need to return the weather report.
- gopi.komanduri May 29, 2013 in India
if weather station exists n functioning properly , will return the weather report of that station .
else ,
will return the nearest available weather station report.
interviewer looking for optimized manner.
looking for datastructures to stores the cities n algo to return the report.| Report Duplicate | Flag | PURGE
Mentor Graphics Analyst Algorithm Arrays Bit Manipulation Brain Teasers C C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming General Questions and Comments Graphics Hash Table Ideas Linked Lists Math & Computation Object Oriented Design Problem Solving Sets Sorting Stacks String Manipulation Terminology & Trivia Threads Trees and Graphs XML - 0of 0 votes
AnswersWhy we use 4X4 matrix for representing and calculations in transformation of 3D points when that can be done only with 3X3 matrix.
- vik February 25, 2013 in United States
(the concept of homogenization of matrices and how they help including translation operation)| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer Intern Graphics - 0of 0 votes
AnswersWhat the different shaders(vetex, geomtery, pixel) describe their roles and the order in which they are executed in graphics pipeline
- vik February 25, 2013 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer Intern Graphics - 0of 0 votes
Answershow would you detect mouth in a picture
- prabhat0189 September 10, 2011 in -| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Graphics