Red Black Tree Insertion Questions why rotate? - red-black-tree

So I have a Red Black Tree as followed:
2 = Root Black
Children = 1 (Black/Left), 4 (Red/Right)
Children of 1 = NIL & NIL => Height of Black Subtree is then 2
Children of 4 = 3 (Black/Left), 5 (Black/Right)
Children of 3 = NIL & NIL, Height of Black Subtree is then 2
Children of 5 = 7 (Red/Right)& NIL, Height is still then of course 2.
So when I insert 6 (of course the color is red) and it goes to be the left child of 7. In this web app I am following, it does a rotation on 6 with 7. Why? It does not seem to violate any properties of the RBT from what I can see.
Note: Source web app is a Java web app that required 1.7
Source: http://gauss.ececs.uc.edu/RedBlackTester/redblack.html

The properties of RBT are.
Every node is either red or black.
The root and leaves (NIL’s) are black.
If a node is red, then its parent is black.
All simple paths from any node x to a
descendant leaf have the same number
of black nodes = black-height(x).
So if 7 is red and and when 6 is added its also red this violates the 3rd property hence the rotation and changes to remove the violations.

Related

autoenablesDefaultLighting is too bright in iOS 12 and SCNView.pointOfView is not effective

I am using SceneKit’s autoenablesDefaultLighting and allowsCameraControl functions of my sceneView to provide light to an obj 3D model in the app and rotate around this object in Objective-C. Since upgrading to iOS12, the default light intensity of autoenablesDefaultLighting gets higher and the 3D model looks so bright!
Did anyone faced the same issue? If yes, is there a way to control the light intensity of autoenablesDefaultLighting when its value is ‘YES’? If it is not editable, I tried to attach/constraint an omni light or directional light to a camera by creating a node, assign a light to this node and add as child of SCNView.pointOfView but no light illuminates the scene.
Exemple:
3D object displayed before iOS 12
3D object displayed in iOS 12
It will be good if anyone can help me on it.
Many thanks!
Edit to solve this issue
I create a new SCNCamera and add this in a node and set the PointOfView of my scnView.
Activate the HDR of this camera with scnView.pointOfView.wantHDR = YES;
but a had a grey background.
To delete the grey background I delete the background color with scnView.backgroundColor = [UIColor ClearColor]
and set the explosure of the camera to -1 with :
self.scnView.pointOfView.camera.minimumExposure = -1;
self.scnView.pointOfView.camera.maximumExposure = -1;
Thanks
You can try enabling HDR. It should result in a balanced exposure
scnView?.pointOfView?.camera?.wantsHDR = true
With HDR enabled, you can even control exposure compensation with
scnView?.pointOfView?.camera?.exposureOffset
.camera?.wantsHDR = true
.camera?.wantsExposureAdaptation = false
Should solve the problem!

SQL Full Text Index Contains

I am fairly new to SQL FTI and I am trying to perfect a search against a table with millions of different product items.
If I pass a search such as this:
select top 100 * from OMG_ProductFeeds.dbo.tbl_products
where CONTAINS(ProductName,'"apple iphone 6"')
I get these results back:
Acm Rich Leather Soft Carry Case For Apple Iphone 6 Mobile Handpouch Holder Cover - Black
Apple iPhone 6 - 16 GB
Apple iPhone 6 Plus - 64 GB
Apple iPhone 6 - 64 GB
Apple iPhone 6 Plus - 16 GB
Chevron Set Of 3 Ultra Clear Screen Guard + 3 Matte Finish Screen Guard For Apple Iphone 6 - Combo Offer
Softy Back Cover Case For Apple Iphone 6 - Golden
Chevron Ultra Clear Hd Finish Screen Guard Protector For Apple Iphone 6 (pack Of 5)
I want to be able to include actual iphone 6 phones but ignore any of the peripherals such as cases and screen protectors but I am not sure how to do this.
Any advice is appreciated.
Thanks
You may consider re-designing your DB structure with a extra table - tbl_product_categories.
In tbl_products we can add a foreign key column to reference the corresponding category from tbl_product_categories. So that you can filter only certain category with certain keyword.
SELECT TOP 100 *
FROM OMG_PRODUCTFEEDS.DBO.TBL_PRODUCTS
WHERE CONTAINS(PRODUCTNAME,'"APPLE IPHONE 6"')
AND product_category_id = 1;

SUSY nth-omega always starts with first element

I am styling my theme on omega4.
On one page I got gallery with 6 elements in 2 rows.
So it looks like
4 elements
2 elements
Each element has class:
.l-content .node{
#include span-columns(4, 16);
#include nth-omega(4n);
}
The problem is that susy starts giving nth-omega style from first and each next 4 node.
I also tried 3n+1, 2n+2 but still same effect.

Small space at the bottom of the device in ios7

We are developing an application working on both ios6 and ios7
My problem is that, If I check my application in device there is a small white space equal to the size of the status bar at the bottom of the screen.
If I put a dummy status bar at the top of the screen it will make problem in ios6, Help me if you have any solution.
That is the common status bar issue while migrating application from IOS 6 to IOS 7 use this to get ride of the issue:
For more reference
https://stackoverflow.com/a/19025547/1545180
You need to set the delta value for all the controls followed by increasing the origin x to 20pix for all the controls.
Step 1: Increase origin y to 20 pixel (for all the controls in the .xib)
step 2 . And set delta y to - 20 for all the controls in Xib.
Step 3 . Finally change the view as version in interface builder.
If your adding the controls programmatically you need to handle the frames (increase the y position based on the version ) of the added controls like this
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f)
{
[_programmaticallyAddedControl setFrame:CGRectMake(20, 36, 176, 428)];
}
else
{
[_programmaticallyAddedControl setFrame:CGRectMake:CGRectMake(20, 56, 176, 428)];
}

Windows 8 periodic tile not updating

I have created a dynamic page for Windows 8 periodic tile updates. The url for the tile is:
http://www.dealsapiens.co.uk/ws/xml.aspx?action=tile
So I try to use the following code:
// update the tile poll URI
var notifications = Windows.UI.Notifications;
var polledUri = new Windows.Foundation.Uri("http://www.dealsapiens.co.uk/ws/xml.aspx?action=tile");
var recurrence = notifications.PeriodicUpdateRecurrence.hour;
var tileUpdater = notifications.TileUpdateManager.createTileUpdaterForApplication();
tileUpdater.startPeriodicUpdate(polledUri, recurrence);
However, when I run and stop the add and go to Start Menu, I do not see the tile images, it just renders a black tile. Any ideas? Do I have some problem with my tile XML?
In your template, you're using invalid id attribute values. The ids correspond to positions within the tile. For the square tile, the id should be 1; for your wide tile you want ids 1 through 5 with each corresponding to the area of the tile that should be occupied by that image.
I've adjusted your tile XML and hosted it at http://jimoneil.blob.core.windows.net/tiles/dealsapiens.xml - give it a shot. It's working on my end.