Starting with an initially empty AVL-tree, draw the resulting AVL-tree after insertion

Starting with an initially empty AVL-tree, draw the resulting AVL-tree after inserting the following elements one after another. 50, 70, 30, 10, 20, 15.

I’m not sure if I am doing it correctly since I am new to AVL trees. Do I rotate if there’s an inequality after the insertion or do I insert everything then only rotate the AVL tree?

Here’s my attempt:

  1. First I insert 50, 70, 30, 10, 20.
      50       /  \     30  70     /    10     \      20 

Then I realise there’s an imbalance so I do a rotation and get

      50       /  \     20  70    /  \   10  30 

There’s one more element to insert which is 15. so, I insert it into the tree

      50       /  \     20  70    /  \   10  30    \     15 

and there’s an imbalance again. So I rotate it

      20      /   \   10    50     \   / \     15 30  70 

My question here is do I insert everything then only rotate or rotate whenever there’s an imbalance while inserting? I did the latter. May I know if my approach is correct? I’m new to AVL trees. Thank you

i will draw simple flat illustration for $20

With just a reference image, idea or concept I will create incredible and colorful vector illustrations in flat design for you, in just 24 hours, work of excellent quality so that you always be satisfied with the results. for only $ 20 get a great basic illustration in this very modern style. Before bidding, do not hesitate to write and arrange the details of the work. for the $ 20 you will get the following files: * JPG * PNG * AI IN VERY GOOD QUALITY BASIC ART DELIVERY IN 24 HOURS

by: kashapovd
Created: —
Category: Art & Design
Viewed: 150


Draw an NFA over {0,1}

enter image description here

if I want to design a NFA (that’s NOT A DFA) that accepts the set of all strings that do not contain the substring 1010, is this correct? because I can just accept 1010 by capturing it in the starting state itself, right?

the starting state accepts 0,1 so I can essentially take the string 1010 and self loop it in the starting state itself… is that correct?

Directx11 batching verticies to draw later

I have several draw functions in my renderer to draw primitives e.g.:

Drawing a Quad:

void Renderer::DrawQuad2D(float left, float bottom, float right, float top, const Rgba& color /*= Rgba::WHITE*/, const Vector4& texCoords /*= Vector4::ZW_AXIS*/) noexcept {     Vector3 v_lb = Vector3(left, bottom, 0.0f);     Vector3 v_rt = Vector3(right, top, 0.0f);     Vector3 v_lt = Vector3(left, top, 0.0f);     Vector3 v_rb = Vector3(right, bottom, 0.0f);     Vector2 uv_lt = Vector2(texCoords.x, texCoords.y);     Vector2 uv_lb = Vector2(texCoords.x, texCoords.w);     Vector2 uv_rt = Vector2(texCoords.z, texCoords.y);     Vector2 uv_rb = Vector2(texCoords.z, texCoords.w);     std::vector<Vertex3D> vbo = {         Vertex3D(v_lb, color, uv_lb)         ,Vertex3D(v_lt, color, uv_lt)         ,Vertex3D(v_rt, color, uv_rt)         ,Vertex3D(v_rb, color, uv_rb)     };     std::vector<unsigned int> ibo = {         0, 1, 2         , 0, 2, 3     };     DrawIndexed(PrimitiveType::Triangles, vbo, ibo);  } 

Sending the verts and indexes to the GPU

void Renderer::DrawIndexed(const PrimitiveType& topology, const std::vector<Vertex3D>& vbo, const std::vector<unsigned int>& ibo) noexcept {     UpdateVbo(vbo);     UpdateIbo(ibo);     DrawIndexed(topology, _temp_vbo.get(), _temp_ibo.get(), ibo.size()); } 

Setup and call DrawIndex on immediate context.

void Renderer::DrawIndexed(const PrimitiveType& topology, VertexBuffer* vbo, IndexBuffer* ibo, std::size_t index_count, std::size_t startVertex /*= 0*/, std::size_t baseVertexLocation /*= 0*/) noexcept {     GUARANTEE_OR_DIE(_current_material, "Attempting to call Draw function without a material set!\n");     D3D11_PRIMITIVE_TOPOLOGY d3d_prim = PrimitiveTypeToD3dTopology(topology);     _rhi_context->GetDxContext()->IASetPrimitiveTopology(d3d_prim);     unsigned int stride = sizeof(VertexBuffer::arraybuffer_t);     unsigned int offsets = 0;     ID3D11Buffer* dx_vbo_buffer = vbo->GetDxBuffer();     ID3D11Buffer* dx_ibo_buffer = ibo->GetDxBuffer();     _rhi_context->GetDxContext()->IASetVertexBuffers(0, 1, &dx_vbo_buffer, &stride, &offsets);     _rhi_context->GetDxContext()->IASetIndexBuffer(dx_ibo_buffer, DXGI_FORMAT_R32_UINT, offsets);     _rhi_context->DrawIndexed(index_count, startVertex, baseVertexLocation); } 

The most noticeable problem is each function issues a draw call. Doing this enough per frame (about 100) causes massive lag. How would I implement a batching such that each of these functions, instead of emitting a draw call immediately, collects all the verts/indexes and doesn’t draw until the end of the frame?

Draw to screen from event handlers

If I have a game traditional game loop like this:

while (true) {     handleEvents(); // Executes any pending event handler     clearScreen();     update();     draw(); } 

How can I execute draw operations from the event handlers? They’ll be cleared. Should I call handleEvents() just after the clearScreen? Usually the event polling is done at the very top of the game loop.

Best ways to draw attention on the ‘winner’ and ‘loser’ within a table

We are building a small tool to compare mortgage terms and their impact on the user’s finances in the long term.

This is our attempt with the table. Our goal is to draw some attention on the 15 year and 30 year results while also showing which term is the better one (green being the ‘winner’ and grey the ‘loser’). How would you best draw attention on the winner’s and loser’s results within a table so that the data in it is easier to digest?

enter image description here

Here’s the full design for context.